001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
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                                            qPos.add(structureIds);
3940                                    }
3941    
3942                                    if (!pagination) {
3943                                            list = (List<JournalArticle>)QueryUtil.list(q,
3944                                                            getDialect(), start, end, false);
3945    
3946                                            Collections.sort(list);
3947    
3948                                            list = new UnmodifiableList<JournalArticle>(list);
3949                                    }
3950                                    else {
3951                                            list = (List<JournalArticle>)QueryUtil.list(q,
3952                                                            getDialect(), start, end);
3953                                    }
3954    
3955                                    cacheResult(list);
3956    
3957                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3958                                            finderArgs, list);
3959                            }
3960                            catch (Exception e) {
3961                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3962                                            finderArgs);
3963    
3964                                    throw processException(e);
3965                            }
3966                            finally {
3967                                    closeSession(session);
3968                            }
3969                    }
3970    
3971                    return list;
3972            }
3973    
3974            /**
3975             * Removes all the journal articles where structureId = &#63; from the database.
3976             *
3977             * @param structureId the structure ID
3978             * @throws SystemException if a system exception occurred
3979             */
3980            @Override
3981            public void removeByStructureId(String structureId)
3982                    throws SystemException {
3983                    for (JournalArticle journalArticle : findByStructureId(structureId,
3984                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3985                            remove(journalArticle);
3986                    }
3987            }
3988    
3989            /**
3990             * Returns the number of journal articles where structureId = &#63;.
3991             *
3992             * @param structureId the structure ID
3993             * @return the number of matching journal articles
3994             * @throws SystemException if a system exception occurred
3995             */
3996            @Override
3997            public int countByStructureId(String structureId) throws SystemException {
3998                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
3999    
4000                    Object[] finderArgs = new Object[] { structureId };
4001    
4002                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4003                                    this);
4004    
4005                    if (count == null) {
4006                            StringBundler query = new StringBundler(2);
4007    
4008                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4009    
4010                            boolean bindStructureId = false;
4011    
4012                            if (structureId == null) {
4013                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4014                            }
4015                            else if (structureId.equals(StringPool.BLANK)) {
4016                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4017                            }
4018                            else {
4019                                    bindStructureId = true;
4020    
4021                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4022                            }
4023    
4024                            String sql = query.toString();
4025    
4026                            Session session = null;
4027    
4028                            try {
4029                                    session = openSession();
4030    
4031                                    Query q = session.createQuery(sql);
4032    
4033                                    QueryPos qPos = QueryPos.getInstance(q);
4034    
4035                                    if (bindStructureId) {
4036                                            qPos.add(structureId);
4037                                    }
4038    
4039                                    count = (Long)q.uniqueResult();
4040    
4041                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4042                            }
4043                            catch (Exception e) {
4044                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4045    
4046                                    throw processException(e);
4047                            }
4048                            finally {
4049                                    closeSession(session);
4050                            }
4051                    }
4052    
4053                    return count.intValue();
4054            }
4055    
4056            /**
4057             * Returns the number of journal articles where structureId = any &#63;.
4058             *
4059             * @param structureIds the structure IDs
4060             * @return the number of matching journal articles
4061             * @throws SystemException if a system exception occurred
4062             */
4063            @Override
4064            public int countByStructureId(String[] structureIds)
4065                    throws SystemException {
4066                    Object[] finderArgs = new Object[] { StringUtil.merge(structureIds) };
4067    
4068                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4069                                    finderArgs, this);
4070    
4071                    if (count == null) {
4072                            StringBundler query = new StringBundler();
4073    
4074                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4075    
4076                            boolean conjunctionable = false;
4077    
4078                            if ((structureIds == null) || (structureIds.length > 0)) {
4079                                    if (conjunctionable) {
4080                                            query.append(WHERE_AND);
4081                                    }
4082    
4083                                    query.append(StringPool.OPEN_PARENTHESIS);
4084    
4085                                    for (int i = 0; i < structureIds.length; i++) {
4086                                            String structureId = structureIds[i];
4087    
4088                                            if (structureId == null) {
4089                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
4090                                            }
4091                                            else if (structureId.equals(StringPool.BLANK)) {
4092                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
4093                                            }
4094                                            else {
4095                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
4096                                            }
4097    
4098                                            if ((i + 1) < structureIds.length) {
4099                                                    query.append(WHERE_OR);
4100                                            }
4101                                    }
4102    
4103                                    query.append(StringPool.CLOSE_PARENTHESIS);
4104    
4105                                    conjunctionable = true;
4106                            }
4107    
4108                            String sql = query.toString();
4109    
4110                            Session session = null;
4111    
4112                            try {
4113                                    session = openSession();
4114    
4115                                    Query q = session.createQuery(sql);
4116    
4117                                    QueryPos qPos = QueryPos.getInstance(q);
4118    
4119                                    if (structureIds != null) {
4120                                            qPos.add(structureIds);
4121                                    }
4122    
4123                                    count = (Long)q.uniqueResult();
4124    
4125                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4126                                            finderArgs, count);
4127                            }
4128                            catch (Exception e) {
4129                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4130                                            finderArgs);
4131    
4132                                    throw processException(e);
4133                            }
4134                            finally {
4135                                    closeSession(session);
4136                            }
4137                    }
4138    
4139                    return count.intValue();
4140            }
4141    
4142            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
4143            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
4144            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
4145            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4 = "(" +
4146                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1) + ")";
4147            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5 = "(" +
4148                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2) + ")";
4149            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6 = "(" +
4150                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3) + ")";
4151            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
4152                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4153                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4154                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4155                            "findByTemplateId",
4156                            new String[] {
4157                                    String.class.getName(),
4158                                    
4159                            Integer.class.getName(), Integer.class.getName(),
4160                                    OrderByComparator.class.getName()
4161                            });
4162            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
4163                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4164                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4165                            JournalArticleImpl.class,
4166                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
4167                            new String[] { String.class.getName() },
4168                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
4169                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4170                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4171            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4172                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4173                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
4174                            new String[] { String.class.getName() });
4175    
4176            /**
4177             * Returns all the journal articles where templateId = &#63;.
4178             *
4179             * @param templateId the template ID
4180             * @return the matching journal articles
4181             * @throws SystemException if a system exception occurred
4182             */
4183            @Override
4184            public List<JournalArticle> findByTemplateId(String templateId)
4185                    throws SystemException {
4186                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4187                            QueryUtil.ALL_POS, null);
4188            }
4189    
4190            /**
4191             * Returns a range of all the journal articles where templateId = &#63;.
4192             *
4193             * <p>
4194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4195             * </p>
4196             *
4197             * @param templateId the template ID
4198             * @param start the lower bound of the range of journal articles
4199             * @param end the upper bound of the range of journal articles (not inclusive)
4200             * @return the range of matching journal articles
4201             * @throws SystemException if a system exception occurred
4202             */
4203            @Override
4204            public List<JournalArticle> findByTemplateId(String templateId, int start,
4205                    int end) throws SystemException {
4206                    return findByTemplateId(templateId, start, end, null);
4207            }
4208    
4209            /**
4210             * Returns an ordered range of all the journal articles where templateId = &#63;.
4211             *
4212             * <p>
4213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4214             * </p>
4215             *
4216             * @param templateId the template ID
4217             * @param start the lower bound of the range of journal articles
4218             * @param end the upper bound of the range of journal articles (not inclusive)
4219             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4220             * @return the ordered range of matching journal articles
4221             * @throws SystemException if a system exception occurred
4222             */
4223            @Override
4224            public List<JournalArticle> findByTemplateId(String templateId, int start,
4225                    int end, OrderByComparator orderByComparator) throws SystemException {
4226                    boolean pagination = true;
4227                    FinderPath finderPath = null;
4228                    Object[] finderArgs = null;
4229    
4230                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4231                                    (orderByComparator == null)) {
4232                            pagination = false;
4233                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4234                            finderArgs = new Object[] { templateId };
4235                    }
4236                    else {
4237                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4238                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4239                    }
4240    
4241                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4242                                    finderArgs, this);
4243    
4244                    if ((list != null) && !list.isEmpty()) {
4245                            for (JournalArticle journalArticle : list) {
4246                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4247                                            list = null;
4248    
4249                                            break;
4250                                    }
4251                            }
4252                    }
4253    
4254                    if (list == null) {
4255                            StringBundler query = null;
4256    
4257                            if (orderByComparator != null) {
4258                                    query = new StringBundler(3 +
4259                                                    (orderByComparator.getOrderByFields().length * 3));
4260                            }
4261                            else {
4262                                    query = new StringBundler(3);
4263                            }
4264    
4265                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4266    
4267                            boolean bindTemplateId = false;
4268    
4269                            if (templateId == null) {
4270                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4271                            }
4272                            else if (templateId.equals(StringPool.BLANK)) {
4273                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4274                            }
4275                            else {
4276                                    bindTemplateId = true;
4277    
4278                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4279                            }
4280    
4281                            if (orderByComparator != null) {
4282                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4283                                            orderByComparator);
4284                            }
4285                            else
4286                             if (pagination) {
4287                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4288                            }
4289    
4290                            String sql = query.toString();
4291    
4292                            Session session = null;
4293    
4294                            try {
4295                                    session = openSession();
4296    
4297                                    Query q = session.createQuery(sql);
4298    
4299                                    QueryPos qPos = QueryPos.getInstance(q);
4300    
4301                                    if (bindTemplateId) {
4302                                            qPos.add(templateId);
4303                                    }
4304    
4305                                    if (!pagination) {
4306                                            list = (List<JournalArticle>)QueryUtil.list(q,
4307                                                            getDialect(), start, end, false);
4308    
4309                                            Collections.sort(list);
4310    
4311                                            list = new UnmodifiableList<JournalArticle>(list);
4312                                    }
4313                                    else {
4314                                            list = (List<JournalArticle>)QueryUtil.list(q,
4315                                                            getDialect(), start, end);
4316                                    }
4317    
4318                                    cacheResult(list);
4319    
4320                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4321                            }
4322                            catch (Exception e) {
4323                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4324    
4325                                    throw processException(e);
4326                            }
4327                            finally {
4328                                    closeSession(session);
4329                            }
4330                    }
4331    
4332                    return list;
4333            }
4334    
4335            /**
4336             * Returns the first journal article in the ordered set where templateId = &#63;.
4337             *
4338             * @param templateId the template ID
4339             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4340             * @return the first matching journal article
4341             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4342             * @throws SystemException if a system exception occurred
4343             */
4344            @Override
4345            public JournalArticle findByTemplateId_First(String templateId,
4346                    OrderByComparator orderByComparator)
4347                    throws NoSuchArticleException, SystemException {
4348                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4349                                    orderByComparator);
4350    
4351                    if (journalArticle != null) {
4352                            return journalArticle;
4353                    }
4354    
4355                    StringBundler msg = new StringBundler(4);
4356    
4357                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4358    
4359                    msg.append("templateId=");
4360                    msg.append(templateId);
4361    
4362                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4363    
4364                    throw new NoSuchArticleException(msg.toString());
4365            }
4366    
4367            /**
4368             * Returns the first journal article in the ordered set where templateId = &#63;.
4369             *
4370             * @param templateId the template ID
4371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4372             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4373             * @throws SystemException if a system exception occurred
4374             */
4375            @Override
4376            public JournalArticle fetchByTemplateId_First(String templateId,
4377                    OrderByComparator orderByComparator) throws SystemException {
4378                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4379                                    orderByComparator);
4380    
4381                    if (!list.isEmpty()) {
4382                            return list.get(0);
4383                    }
4384    
4385                    return null;
4386            }
4387    
4388            /**
4389             * Returns the last journal article in the ordered set where templateId = &#63;.
4390             *
4391             * @param templateId the template ID
4392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4393             * @return the last matching journal article
4394             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4395             * @throws SystemException if a system exception occurred
4396             */
4397            @Override
4398            public JournalArticle findByTemplateId_Last(String templateId,
4399                    OrderByComparator orderByComparator)
4400                    throws NoSuchArticleException, SystemException {
4401                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4402                                    orderByComparator);
4403    
4404                    if (journalArticle != null) {
4405                            return journalArticle;
4406                    }
4407    
4408                    StringBundler msg = new StringBundler(4);
4409    
4410                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4411    
4412                    msg.append("templateId=");
4413                    msg.append(templateId);
4414    
4415                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4416    
4417                    throw new NoSuchArticleException(msg.toString());
4418            }
4419    
4420            /**
4421             * Returns the last journal article in the ordered set where templateId = &#63;.
4422             *
4423             * @param templateId the template ID
4424             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4425             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4426             * @throws SystemException if a system exception occurred
4427             */
4428            @Override
4429            public JournalArticle fetchByTemplateId_Last(String templateId,
4430                    OrderByComparator orderByComparator) throws SystemException {
4431                    int count = countByTemplateId(templateId);
4432    
4433                    if (count == 0) {
4434                            return null;
4435                    }
4436    
4437                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4438                                    count, orderByComparator);
4439    
4440                    if (!list.isEmpty()) {
4441                            return list.get(0);
4442                    }
4443    
4444                    return null;
4445            }
4446    
4447            /**
4448             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4449             *
4450             * @param id the primary key of the current journal article
4451             * @param templateId the template ID
4452             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4453             * @return the previous, current, and next journal article
4454             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4455             * @throws SystemException if a system exception occurred
4456             */
4457            @Override
4458            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4459                    String templateId, OrderByComparator orderByComparator)
4460                    throws NoSuchArticleException, SystemException {
4461                    JournalArticle journalArticle = findByPrimaryKey(id);
4462    
4463                    Session session = null;
4464    
4465                    try {
4466                            session = openSession();
4467    
4468                            JournalArticle[] array = new JournalArticleImpl[3];
4469    
4470                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4471                                            templateId, orderByComparator, true);
4472    
4473                            array[1] = journalArticle;
4474    
4475                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4476                                            templateId, orderByComparator, false);
4477    
4478                            return array;
4479                    }
4480                    catch (Exception e) {
4481                            throw processException(e);
4482                    }
4483                    finally {
4484                            closeSession(session);
4485                    }
4486            }
4487    
4488            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4489                    JournalArticle journalArticle, String templateId,
4490                    OrderByComparator orderByComparator, boolean previous) {
4491                    StringBundler query = null;
4492    
4493                    if (orderByComparator != null) {
4494                            query = new StringBundler(6 +
4495                                            (orderByComparator.getOrderByFields().length * 6));
4496                    }
4497                    else {
4498                            query = new StringBundler(3);
4499                    }
4500    
4501                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4502    
4503                    boolean bindTemplateId = false;
4504    
4505                    if (templateId == null) {
4506                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4507                    }
4508                    else if (templateId.equals(StringPool.BLANK)) {
4509                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4510                    }
4511                    else {
4512                            bindTemplateId = true;
4513    
4514                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4515                    }
4516    
4517                    if (orderByComparator != null) {
4518                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4519    
4520                            if (orderByConditionFields.length > 0) {
4521                                    query.append(WHERE_AND);
4522                            }
4523    
4524                            for (int i = 0; i < orderByConditionFields.length; i++) {
4525                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4526                                    query.append(orderByConditionFields[i]);
4527    
4528                                    if ((i + 1) < orderByConditionFields.length) {
4529                                            if (orderByComparator.isAscending() ^ previous) {
4530                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4531                                            }
4532                                            else {
4533                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4534                                            }
4535                                    }
4536                                    else {
4537                                            if (orderByComparator.isAscending() ^ previous) {
4538                                                    query.append(WHERE_GREATER_THAN);
4539                                            }
4540                                            else {
4541                                                    query.append(WHERE_LESSER_THAN);
4542                                            }
4543                                    }
4544                            }
4545    
4546                            query.append(ORDER_BY_CLAUSE);
4547    
4548                            String[] orderByFields = orderByComparator.getOrderByFields();
4549    
4550                            for (int i = 0; i < orderByFields.length; i++) {
4551                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4552                                    query.append(orderByFields[i]);
4553    
4554                                    if ((i + 1) < orderByFields.length) {
4555                                            if (orderByComparator.isAscending() ^ previous) {
4556                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4557                                            }
4558                                            else {
4559                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4560                                            }
4561                                    }
4562                                    else {
4563                                            if (orderByComparator.isAscending() ^ previous) {
4564                                                    query.append(ORDER_BY_ASC);
4565                                            }
4566                                            else {
4567                                                    query.append(ORDER_BY_DESC);
4568                                            }
4569                                    }
4570                            }
4571                    }
4572                    else {
4573                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4574                    }
4575    
4576                    String sql = query.toString();
4577    
4578                    Query q = session.createQuery(sql);
4579    
4580                    q.setFirstResult(0);
4581                    q.setMaxResults(2);
4582    
4583                    QueryPos qPos = QueryPos.getInstance(q);
4584    
4585                    if (bindTemplateId) {
4586                            qPos.add(templateId);
4587                    }
4588    
4589                    if (orderByComparator != null) {
4590                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4591    
4592                            for (Object value : values) {
4593                                    qPos.add(value);
4594                            }
4595                    }
4596    
4597                    List<JournalArticle> list = q.list();
4598    
4599                    if (list.size() == 2) {
4600                            return list.get(1);
4601                    }
4602                    else {
4603                            return null;
4604                    }
4605            }
4606    
4607            /**
4608             * Removes all the journal articles where templateId = &#63; from the database.
4609             *
4610             * @param templateId the template ID
4611             * @throws SystemException if a system exception occurred
4612             */
4613            @Override
4614            public void removeByTemplateId(String templateId) throws SystemException {
4615                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4616                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4617                            remove(journalArticle);
4618                    }
4619            }
4620    
4621            /**
4622             * Returns the number of journal articles where templateId = &#63;.
4623             *
4624             * @param templateId the template ID
4625             * @return the number of matching journal articles
4626             * @throws SystemException if a system exception occurred
4627             */
4628            @Override
4629            public int countByTemplateId(String templateId) throws SystemException {
4630                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4631    
4632                    Object[] finderArgs = new Object[] { templateId };
4633    
4634                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4635                                    this);
4636    
4637                    if (count == null) {
4638                            StringBundler query = new StringBundler(2);
4639    
4640                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4641    
4642                            boolean bindTemplateId = false;
4643    
4644                            if (templateId == null) {
4645                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4646                            }
4647                            else if (templateId.equals(StringPool.BLANK)) {
4648                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4649                            }
4650                            else {
4651                                    bindTemplateId = true;
4652    
4653                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4654                            }
4655    
4656                            String sql = query.toString();
4657    
4658                            Session session = null;
4659    
4660                            try {
4661                                    session = openSession();
4662    
4663                                    Query q = session.createQuery(sql);
4664    
4665                                    QueryPos qPos = QueryPos.getInstance(q);
4666    
4667                                    if (bindTemplateId) {
4668                                            qPos.add(templateId);
4669                                    }
4670    
4671                                    count = (Long)q.uniqueResult();
4672    
4673                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4674                            }
4675                            catch (Exception e) {
4676                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4677    
4678                                    throw processException(e);
4679                            }
4680                            finally {
4681                                    closeSession(session);
4682                            }
4683                    }
4684    
4685                    return count.intValue();
4686            }
4687    
4688            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4689            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4690            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
4691            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4692                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4693                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4694                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4695                            "findByLayoutUuid",
4696                            new String[] {
4697                                    String.class.getName(),
4698                                    
4699                            Integer.class.getName(), Integer.class.getName(),
4700                                    OrderByComparator.class.getName()
4701                            });
4702            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4703                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4704                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4705                            JournalArticleImpl.class,
4706                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4707                            new String[] { String.class.getName() },
4708                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4709                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4710                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4711            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4712                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4713                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4714                            new String[] { String.class.getName() });
4715    
4716            /**
4717             * Returns all the journal articles where layoutUuid = &#63;.
4718             *
4719             * @param layoutUuid the layout uuid
4720             * @return the matching journal articles
4721             * @throws SystemException if a system exception occurred
4722             */
4723            @Override
4724            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
4725                    throws SystemException {
4726                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4727                            QueryUtil.ALL_POS, null);
4728            }
4729    
4730            /**
4731             * Returns a range of all the journal articles where layoutUuid = &#63;.
4732             *
4733             * <p>
4734             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4735             * </p>
4736             *
4737             * @param layoutUuid the layout uuid
4738             * @param start the lower bound of the range of journal articles
4739             * @param end the upper bound of the range of journal articles (not inclusive)
4740             * @return the range of matching journal articles
4741             * @throws SystemException if a system exception occurred
4742             */
4743            @Override
4744            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4745                    int end) throws SystemException {
4746                    return findByLayoutUuid(layoutUuid, start, end, null);
4747            }
4748    
4749            /**
4750             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4751             *
4752             * <p>
4753             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4754             * </p>
4755             *
4756             * @param layoutUuid the layout uuid
4757             * @param start the lower bound of the range of journal articles
4758             * @param end the upper bound of the range of journal articles (not inclusive)
4759             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4760             * @return the ordered range of matching journal articles
4761             * @throws SystemException if a system exception occurred
4762             */
4763            @Override
4764            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4765                    int end, OrderByComparator orderByComparator) throws SystemException {
4766                    boolean pagination = true;
4767                    FinderPath finderPath = null;
4768                    Object[] finderArgs = null;
4769    
4770                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4771                                    (orderByComparator == null)) {
4772                            pagination = false;
4773                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4774                            finderArgs = new Object[] { layoutUuid };
4775                    }
4776                    else {
4777                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4778                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4779                    }
4780    
4781                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4782                                    finderArgs, this);
4783    
4784                    if ((list != null) && !list.isEmpty()) {
4785                            for (JournalArticle journalArticle : list) {
4786                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4787                                            list = null;
4788    
4789                                            break;
4790                                    }
4791                            }
4792                    }
4793    
4794                    if (list == null) {
4795                            StringBundler query = null;
4796    
4797                            if (orderByComparator != null) {
4798                                    query = new StringBundler(3 +
4799                                                    (orderByComparator.getOrderByFields().length * 3));
4800                            }
4801                            else {
4802                                    query = new StringBundler(3);
4803                            }
4804    
4805                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4806    
4807                            boolean bindLayoutUuid = false;
4808    
4809                            if (layoutUuid == null) {
4810                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4811                            }
4812                            else if (layoutUuid.equals(StringPool.BLANK)) {
4813                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4814                            }
4815                            else {
4816                                    bindLayoutUuid = true;
4817    
4818                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4819                            }
4820    
4821                            if (orderByComparator != null) {
4822                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4823                                            orderByComparator);
4824                            }
4825                            else
4826                             if (pagination) {
4827                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4828                            }
4829    
4830                            String sql = query.toString();
4831    
4832                            Session session = null;
4833    
4834                            try {
4835                                    session = openSession();
4836    
4837                                    Query q = session.createQuery(sql);
4838    
4839                                    QueryPos qPos = QueryPos.getInstance(q);
4840    
4841                                    if (bindLayoutUuid) {
4842                                            qPos.add(layoutUuid);
4843                                    }
4844    
4845                                    if (!pagination) {
4846                                            list = (List<JournalArticle>)QueryUtil.list(q,
4847                                                            getDialect(), start, end, false);
4848    
4849                                            Collections.sort(list);
4850    
4851                                            list = new UnmodifiableList<JournalArticle>(list);
4852                                    }
4853                                    else {
4854                                            list = (List<JournalArticle>)QueryUtil.list(q,
4855                                                            getDialect(), start, end);
4856                                    }
4857    
4858                                    cacheResult(list);
4859    
4860                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4861                            }
4862                            catch (Exception e) {
4863                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4864    
4865                                    throw processException(e);
4866                            }
4867                            finally {
4868                                    closeSession(session);
4869                            }
4870                    }
4871    
4872                    return list;
4873            }
4874    
4875            /**
4876             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4877             *
4878             * @param layoutUuid the layout uuid
4879             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4880             * @return the first matching journal article
4881             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4882             * @throws SystemException if a system exception occurred
4883             */
4884            @Override
4885            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4886                    OrderByComparator orderByComparator)
4887                    throws NoSuchArticleException, SystemException {
4888                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4889                                    orderByComparator);
4890    
4891                    if (journalArticle != null) {
4892                            return journalArticle;
4893                    }
4894    
4895                    StringBundler msg = new StringBundler(4);
4896    
4897                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4898    
4899                    msg.append("layoutUuid=");
4900                    msg.append(layoutUuid);
4901    
4902                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4903    
4904                    throw new NoSuchArticleException(msg.toString());
4905            }
4906    
4907            /**
4908             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4909             *
4910             * @param layoutUuid the layout uuid
4911             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4912             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4913             * @throws SystemException if a system exception occurred
4914             */
4915            @Override
4916            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4917                    OrderByComparator orderByComparator) throws SystemException {
4918                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4919                                    orderByComparator);
4920    
4921                    if (!list.isEmpty()) {
4922                            return list.get(0);
4923                    }
4924    
4925                    return null;
4926            }
4927    
4928            /**
4929             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4930             *
4931             * @param layoutUuid the layout uuid
4932             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4933             * @return the last matching journal article
4934             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4935             * @throws SystemException if a system exception occurred
4936             */
4937            @Override
4938            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4939                    OrderByComparator orderByComparator)
4940                    throws NoSuchArticleException, SystemException {
4941                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4942                                    orderByComparator);
4943    
4944                    if (journalArticle != null) {
4945                            return journalArticle;
4946                    }
4947    
4948                    StringBundler msg = new StringBundler(4);
4949    
4950                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4951    
4952                    msg.append("layoutUuid=");
4953                    msg.append(layoutUuid);
4954    
4955                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4956    
4957                    throw new NoSuchArticleException(msg.toString());
4958            }
4959    
4960            /**
4961             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4962             *
4963             * @param layoutUuid the layout uuid
4964             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4965             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4966             * @throws SystemException if a system exception occurred
4967             */
4968            @Override
4969            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4970                    OrderByComparator orderByComparator) throws SystemException {
4971                    int count = countByLayoutUuid(layoutUuid);
4972    
4973                    if (count == 0) {
4974                            return null;
4975                    }
4976    
4977                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4978                                    count, orderByComparator);
4979    
4980                    if (!list.isEmpty()) {
4981                            return list.get(0);
4982                    }
4983    
4984                    return null;
4985            }
4986    
4987            /**
4988             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4989             *
4990             * @param id the primary key of the current journal article
4991             * @param layoutUuid the layout uuid
4992             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4993             * @return the previous, current, and next journal article
4994             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4995             * @throws SystemException if a system exception occurred
4996             */
4997            @Override
4998            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4999                    String layoutUuid, OrderByComparator orderByComparator)
5000                    throws NoSuchArticleException, SystemException {
5001                    JournalArticle journalArticle = findByPrimaryKey(id);
5002    
5003                    Session session = null;
5004    
5005                    try {
5006                            session = openSession();
5007    
5008                            JournalArticle[] array = new JournalArticleImpl[3];
5009    
5010                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5011                                            layoutUuid, orderByComparator, true);
5012    
5013                            array[1] = journalArticle;
5014    
5015                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5016                                            layoutUuid, orderByComparator, false);
5017    
5018                            return array;
5019                    }
5020                    catch (Exception e) {
5021                            throw processException(e);
5022                    }
5023                    finally {
5024                            closeSession(session);
5025                    }
5026            }
5027    
5028            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
5029                    JournalArticle journalArticle, String layoutUuid,
5030                    OrderByComparator orderByComparator, boolean previous) {
5031                    StringBundler query = null;
5032    
5033                    if (orderByComparator != null) {
5034                            query = new StringBundler(6 +
5035                                            (orderByComparator.getOrderByFields().length * 6));
5036                    }
5037                    else {
5038                            query = new StringBundler(3);
5039                    }
5040    
5041                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5042    
5043                    boolean bindLayoutUuid = false;
5044    
5045                    if (layoutUuid == null) {
5046                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5047                    }
5048                    else if (layoutUuid.equals(StringPool.BLANK)) {
5049                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5050                    }
5051                    else {
5052                            bindLayoutUuid = true;
5053    
5054                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5055                    }
5056    
5057                    if (orderByComparator != null) {
5058                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5059    
5060                            if (orderByConditionFields.length > 0) {
5061                                    query.append(WHERE_AND);
5062                            }
5063    
5064                            for (int i = 0; i < orderByConditionFields.length; i++) {
5065                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5066                                    query.append(orderByConditionFields[i]);
5067    
5068                                    if ((i + 1) < orderByConditionFields.length) {
5069                                            if (orderByComparator.isAscending() ^ previous) {
5070                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5071                                            }
5072                                            else {
5073                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5074                                            }
5075                                    }
5076                                    else {
5077                                            if (orderByComparator.isAscending() ^ previous) {
5078                                                    query.append(WHERE_GREATER_THAN);
5079                                            }
5080                                            else {
5081                                                    query.append(WHERE_LESSER_THAN);
5082                                            }
5083                                    }
5084                            }
5085    
5086                            query.append(ORDER_BY_CLAUSE);
5087    
5088                            String[] orderByFields = orderByComparator.getOrderByFields();
5089    
5090                            for (int i = 0; i < orderByFields.length; i++) {
5091                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5092                                    query.append(orderByFields[i]);
5093    
5094                                    if ((i + 1) < orderByFields.length) {
5095                                            if (orderByComparator.isAscending() ^ previous) {
5096                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5097                                            }
5098                                            else {
5099                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5100                                            }
5101                                    }
5102                                    else {
5103                                            if (orderByComparator.isAscending() ^ previous) {
5104                                                    query.append(ORDER_BY_ASC);
5105                                            }
5106                                            else {
5107                                                    query.append(ORDER_BY_DESC);
5108                                            }
5109                                    }
5110                            }
5111                    }
5112                    else {
5113                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5114                    }
5115    
5116                    String sql = query.toString();
5117    
5118                    Query q = session.createQuery(sql);
5119    
5120                    q.setFirstResult(0);
5121                    q.setMaxResults(2);
5122    
5123                    QueryPos qPos = QueryPos.getInstance(q);
5124    
5125                    if (bindLayoutUuid) {
5126                            qPos.add(layoutUuid);
5127                    }
5128    
5129                    if (orderByComparator != null) {
5130                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5131    
5132                            for (Object value : values) {
5133                                    qPos.add(value);
5134                            }
5135                    }
5136    
5137                    List<JournalArticle> list = q.list();
5138    
5139                    if (list.size() == 2) {
5140                            return list.get(1);
5141                    }
5142                    else {
5143                            return null;
5144                    }
5145            }
5146    
5147            /**
5148             * Removes all the journal articles where layoutUuid = &#63; from the database.
5149             *
5150             * @param layoutUuid the layout uuid
5151             * @throws SystemException if a system exception occurred
5152             */
5153            @Override
5154            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
5155                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
5156                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5157                            remove(journalArticle);
5158                    }
5159            }
5160    
5161            /**
5162             * Returns the number of journal articles where layoutUuid = &#63;.
5163             *
5164             * @param layoutUuid the layout uuid
5165             * @return the number of matching journal articles
5166             * @throws SystemException if a system exception occurred
5167             */
5168            @Override
5169            public int countByLayoutUuid(String layoutUuid) throws SystemException {
5170                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
5171    
5172                    Object[] finderArgs = new Object[] { layoutUuid };
5173    
5174                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5175                                    this);
5176    
5177                    if (count == null) {
5178                            StringBundler query = new StringBundler(2);
5179    
5180                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5181    
5182                            boolean bindLayoutUuid = false;
5183    
5184                            if (layoutUuid == null) {
5185                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5186                            }
5187                            else if (layoutUuid.equals(StringPool.BLANK)) {
5188                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5189                            }
5190                            else {
5191                                    bindLayoutUuid = true;
5192    
5193                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5194                            }
5195    
5196                            String sql = query.toString();
5197    
5198                            Session session = null;
5199    
5200                            try {
5201                                    session = openSession();
5202    
5203                                    Query q = session.createQuery(sql);
5204    
5205                                    QueryPos qPos = QueryPos.getInstance(q);
5206    
5207                                    if (bindLayoutUuid) {
5208                                            qPos.add(layoutUuid);
5209                                    }
5210    
5211                                    count = (Long)q.uniqueResult();
5212    
5213                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5214                            }
5215                            catch (Exception e) {
5216                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5217    
5218                                    throw processException(e);
5219                            }
5220                            finally {
5221                                    closeSession(session);
5222                            }
5223                    }
5224    
5225                    return count.intValue();
5226            }
5227    
5228            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
5229            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
5230            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
5231            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
5232                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5233                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5234                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5235                            "findBySmallImageId",
5236                            new String[] {
5237                                    Long.class.getName(),
5238                                    
5239                            Integer.class.getName(), Integer.class.getName(),
5240                                    OrderByComparator.class.getName()
5241                            });
5242            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
5243                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5244                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5245                            JournalArticleImpl.class,
5246                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
5247                            new String[] { Long.class.getName() },
5248                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
5249                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5250                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5251            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5252                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5253                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
5254                            new String[] { Long.class.getName() });
5255    
5256            /**
5257             * Returns all the journal articles where smallImageId = &#63;.
5258             *
5259             * @param smallImageId the small image ID
5260             * @return the matching journal articles
5261             * @throws SystemException if a system exception occurred
5262             */
5263            @Override
5264            public List<JournalArticle> findBySmallImageId(long smallImageId)
5265                    throws SystemException {
5266                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5267                            QueryUtil.ALL_POS, null);
5268            }
5269    
5270            /**
5271             * Returns a range of all the journal articles where smallImageId = &#63;.
5272             *
5273             * <p>
5274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5275             * </p>
5276             *
5277             * @param smallImageId the small image ID
5278             * @param start the lower bound of the range of journal articles
5279             * @param end the upper bound of the range of journal articles (not inclusive)
5280             * @return the range of matching journal articles
5281             * @throws SystemException if a system exception occurred
5282             */
5283            @Override
5284            public List<JournalArticle> findBySmallImageId(long smallImageId,
5285                    int start, int end) throws SystemException {
5286                    return findBySmallImageId(smallImageId, start, end, null);
5287            }
5288    
5289            /**
5290             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5291             *
5292             * <p>
5293             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5294             * </p>
5295             *
5296             * @param smallImageId the small image ID
5297             * @param start the lower bound of the range of journal articles
5298             * @param end the upper bound of the range of journal articles (not inclusive)
5299             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5300             * @return the ordered range of matching journal articles
5301             * @throws SystemException if a system exception occurred
5302             */
5303            @Override
5304            public List<JournalArticle> findBySmallImageId(long smallImageId,
5305                    int start, int end, OrderByComparator orderByComparator)
5306                    throws SystemException {
5307                    boolean pagination = true;
5308                    FinderPath finderPath = null;
5309                    Object[] finderArgs = null;
5310    
5311                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5312                                    (orderByComparator == null)) {
5313                            pagination = false;
5314                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5315                            finderArgs = new Object[] { smallImageId };
5316                    }
5317                    else {
5318                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5319                            finderArgs = new Object[] {
5320                                            smallImageId,
5321                                            
5322                                            start, end, orderByComparator
5323                                    };
5324                    }
5325    
5326                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5327                                    finderArgs, this);
5328    
5329                    if ((list != null) && !list.isEmpty()) {
5330                            for (JournalArticle journalArticle : list) {
5331                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5332                                            list = null;
5333    
5334                                            break;
5335                                    }
5336                            }
5337                    }
5338    
5339                    if (list == null) {
5340                            StringBundler query = null;
5341    
5342                            if (orderByComparator != null) {
5343                                    query = new StringBundler(3 +
5344                                                    (orderByComparator.getOrderByFields().length * 3));
5345                            }
5346                            else {
5347                                    query = new StringBundler(3);
5348                            }
5349    
5350                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5351    
5352                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5353    
5354                            if (orderByComparator != null) {
5355                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5356                                            orderByComparator);
5357                            }
5358                            else
5359                             if (pagination) {
5360                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5361                            }
5362    
5363                            String sql = query.toString();
5364    
5365                            Session session = null;
5366    
5367                            try {
5368                                    session = openSession();
5369    
5370                                    Query q = session.createQuery(sql);
5371    
5372                                    QueryPos qPos = QueryPos.getInstance(q);
5373    
5374                                    qPos.add(smallImageId);
5375    
5376                                    if (!pagination) {
5377                                            list = (List<JournalArticle>)QueryUtil.list(q,
5378                                                            getDialect(), start, end, false);
5379    
5380                                            Collections.sort(list);
5381    
5382                                            list = new UnmodifiableList<JournalArticle>(list);
5383                                    }
5384                                    else {
5385                                            list = (List<JournalArticle>)QueryUtil.list(q,
5386                                                            getDialect(), start, end);
5387                                    }
5388    
5389                                    cacheResult(list);
5390    
5391                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5392                            }
5393                            catch (Exception e) {
5394                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5395    
5396                                    throw processException(e);
5397                            }
5398                            finally {
5399                                    closeSession(session);
5400                            }
5401                    }
5402    
5403                    return list;
5404            }
5405    
5406            /**
5407             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5408             *
5409             * @param smallImageId the small image ID
5410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5411             * @return the first matching journal article
5412             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5413             * @throws SystemException if a system exception occurred
5414             */
5415            @Override
5416            public JournalArticle findBySmallImageId_First(long smallImageId,
5417                    OrderByComparator orderByComparator)
5418                    throws NoSuchArticleException, SystemException {
5419                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5420                                    orderByComparator);
5421    
5422                    if (journalArticle != null) {
5423                            return journalArticle;
5424                    }
5425    
5426                    StringBundler msg = new StringBundler(4);
5427    
5428                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5429    
5430                    msg.append("smallImageId=");
5431                    msg.append(smallImageId);
5432    
5433                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5434    
5435                    throw new NoSuchArticleException(msg.toString());
5436            }
5437    
5438            /**
5439             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5440             *
5441             * @param smallImageId the small image ID
5442             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5443             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5444             * @throws SystemException if a system exception occurred
5445             */
5446            @Override
5447            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5448                    OrderByComparator orderByComparator) throws SystemException {
5449                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5450                                    orderByComparator);
5451    
5452                    if (!list.isEmpty()) {
5453                            return list.get(0);
5454                    }
5455    
5456                    return null;
5457            }
5458    
5459            /**
5460             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5461             *
5462             * @param smallImageId the small image ID
5463             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5464             * @return the last matching journal article
5465             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5466             * @throws SystemException if a system exception occurred
5467             */
5468            @Override
5469            public JournalArticle findBySmallImageId_Last(long smallImageId,
5470                    OrderByComparator orderByComparator)
5471                    throws NoSuchArticleException, SystemException {
5472                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5473                                    orderByComparator);
5474    
5475                    if (journalArticle != null) {
5476                            return journalArticle;
5477                    }
5478    
5479                    StringBundler msg = new StringBundler(4);
5480    
5481                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5482    
5483                    msg.append("smallImageId=");
5484                    msg.append(smallImageId);
5485    
5486                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5487    
5488                    throw new NoSuchArticleException(msg.toString());
5489            }
5490    
5491            /**
5492             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5493             *
5494             * @param smallImageId the small image ID
5495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5496             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5497             * @throws SystemException if a system exception occurred
5498             */
5499            @Override
5500            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5501                    OrderByComparator orderByComparator) throws SystemException {
5502                    int count = countBySmallImageId(smallImageId);
5503    
5504                    if (count == 0) {
5505                            return null;
5506                    }
5507    
5508                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5509                                    count, orderByComparator);
5510    
5511                    if (!list.isEmpty()) {
5512                            return list.get(0);
5513                    }
5514    
5515                    return null;
5516            }
5517    
5518            /**
5519             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5520             *
5521             * @param id the primary key of the current journal article
5522             * @param smallImageId the small image ID
5523             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5524             * @return the previous, current, and next journal article
5525             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5526             * @throws SystemException if a system exception occurred
5527             */
5528            @Override
5529            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5530                    long smallImageId, OrderByComparator orderByComparator)
5531                    throws NoSuchArticleException, SystemException {
5532                    JournalArticle journalArticle = findByPrimaryKey(id);
5533    
5534                    Session session = null;
5535    
5536                    try {
5537                            session = openSession();
5538    
5539                            JournalArticle[] array = new JournalArticleImpl[3];
5540    
5541                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5542                                            smallImageId, orderByComparator, true);
5543    
5544                            array[1] = journalArticle;
5545    
5546                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5547                                            smallImageId, orderByComparator, false);
5548    
5549                            return array;
5550                    }
5551                    catch (Exception e) {
5552                            throw processException(e);
5553                    }
5554                    finally {
5555                            closeSession(session);
5556                    }
5557            }
5558    
5559            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5560                    JournalArticle journalArticle, long smallImageId,
5561                    OrderByComparator orderByComparator, boolean previous) {
5562                    StringBundler query = null;
5563    
5564                    if (orderByComparator != null) {
5565                            query = new StringBundler(6 +
5566                                            (orderByComparator.getOrderByFields().length * 6));
5567                    }
5568                    else {
5569                            query = new StringBundler(3);
5570                    }
5571    
5572                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5573    
5574                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5575    
5576                    if (orderByComparator != null) {
5577                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5578    
5579                            if (orderByConditionFields.length > 0) {
5580                                    query.append(WHERE_AND);
5581                            }
5582    
5583                            for (int i = 0; i < orderByConditionFields.length; i++) {
5584                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5585                                    query.append(orderByConditionFields[i]);
5586    
5587                                    if ((i + 1) < orderByConditionFields.length) {
5588                                            if (orderByComparator.isAscending() ^ previous) {
5589                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5590                                            }
5591                                            else {
5592                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5593                                            }
5594                                    }
5595                                    else {
5596                                            if (orderByComparator.isAscending() ^ previous) {
5597                                                    query.append(WHERE_GREATER_THAN);
5598                                            }
5599                                            else {
5600                                                    query.append(WHERE_LESSER_THAN);
5601                                            }
5602                                    }
5603                            }
5604    
5605                            query.append(ORDER_BY_CLAUSE);
5606    
5607                            String[] orderByFields = orderByComparator.getOrderByFields();
5608    
5609                            for (int i = 0; i < orderByFields.length; i++) {
5610                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5611                                    query.append(orderByFields[i]);
5612    
5613                                    if ((i + 1) < orderByFields.length) {
5614                                            if (orderByComparator.isAscending() ^ previous) {
5615                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5616                                            }
5617                                            else {
5618                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5619                                            }
5620                                    }
5621                                    else {
5622                                            if (orderByComparator.isAscending() ^ previous) {
5623                                                    query.append(ORDER_BY_ASC);
5624                                            }
5625                                            else {
5626                                                    query.append(ORDER_BY_DESC);
5627                                            }
5628                                    }
5629                            }
5630                    }
5631                    else {
5632                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5633                    }
5634    
5635                    String sql = query.toString();
5636    
5637                    Query q = session.createQuery(sql);
5638    
5639                    q.setFirstResult(0);
5640                    q.setMaxResults(2);
5641    
5642                    QueryPos qPos = QueryPos.getInstance(q);
5643    
5644                    qPos.add(smallImageId);
5645    
5646                    if (orderByComparator != null) {
5647                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5648    
5649                            for (Object value : values) {
5650                                    qPos.add(value);
5651                            }
5652                    }
5653    
5654                    List<JournalArticle> list = q.list();
5655    
5656                    if (list.size() == 2) {
5657                            return list.get(1);
5658                    }
5659                    else {
5660                            return null;
5661                    }
5662            }
5663    
5664            /**
5665             * Removes all the journal articles where smallImageId = &#63; from the database.
5666             *
5667             * @param smallImageId the small image ID
5668             * @throws SystemException if a system exception occurred
5669             */
5670            @Override
5671            public void removeBySmallImageId(long smallImageId)
5672                    throws SystemException {
5673                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5674                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5675                            remove(journalArticle);
5676                    }
5677            }
5678    
5679            /**
5680             * Returns the number of journal articles where smallImageId = &#63;.
5681             *
5682             * @param smallImageId the small image ID
5683             * @return the number of matching journal articles
5684             * @throws SystemException if a system exception occurred
5685             */
5686            @Override
5687            public int countBySmallImageId(long smallImageId) throws SystemException {
5688                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5689    
5690                    Object[] finderArgs = new Object[] { smallImageId };
5691    
5692                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5693                                    this);
5694    
5695                    if (count == null) {
5696                            StringBundler query = new StringBundler(2);
5697    
5698                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5699    
5700                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5701    
5702                            String sql = query.toString();
5703    
5704                            Session session = null;
5705    
5706                            try {
5707                                    session = openSession();
5708    
5709                                    Query q = session.createQuery(sql);
5710    
5711                                    QueryPos qPos = QueryPos.getInstance(q);
5712    
5713                                    qPos.add(smallImageId);
5714    
5715                                    count = (Long)q.uniqueResult();
5716    
5717                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5718                            }
5719                            catch (Exception e) {
5720                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5721    
5722                                    throw processException(e);
5723                            }
5724                            finally {
5725                                    closeSession(session);
5726                            }
5727                    }
5728    
5729                    return count.intValue();
5730            }
5731    
5732            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5733            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5734                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5735                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5736                            "findByR_I",
5737                            new String[] {
5738                                    Long.class.getName(), Boolean.class.getName(),
5739                                    
5740                            Integer.class.getName(), Integer.class.getName(),
5741                                    OrderByComparator.class.getName()
5742                            });
5743            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5744                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5745                            JournalArticleImpl.class,
5746                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I",
5747                            new String[] { Long.class.getName(), Boolean.class.getName() },
5748                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5749                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
5750                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5751                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5752            public static final FinderPath FINDER_PATH_COUNT_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5753                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5754                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I",
5755                            new String[] { Long.class.getName(), Boolean.class.getName() });
5756    
5757            /**
5758             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5759             *
5760             * @param resourcePrimKey the resource prim key
5761             * @param indexable the indexable
5762             * @return the matching journal articles
5763             * @throws SystemException if a system exception occurred
5764             */
5765            @Override
5766            public List<JournalArticle> findByR_I(long resourcePrimKey,
5767                    boolean indexable) throws SystemException {
5768                    return findByR_I(resourcePrimKey, indexable, QueryUtil.ALL_POS,
5769                            QueryUtil.ALL_POS, null);
5770            }
5771    
5772            /**
5773             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5774             *
5775             * <p>
5776             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5777             * </p>
5778             *
5779             * @param resourcePrimKey the resource prim key
5780             * @param indexable the indexable
5781             * @param start the lower bound of the range of journal articles
5782             * @param end the upper bound of the range of journal articles (not inclusive)
5783             * @return the range of matching journal articles
5784             * @throws SystemException if a system exception occurred
5785             */
5786            @Override
5787            public List<JournalArticle> findByR_I(long resourcePrimKey,
5788                    boolean indexable, int start, int end) throws SystemException {
5789                    return findByR_I(resourcePrimKey, indexable, start, end, null);
5790            }
5791    
5792            /**
5793             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5794             *
5795             * <p>
5796             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5797             * </p>
5798             *
5799             * @param resourcePrimKey the resource prim key
5800             * @param indexable the indexable
5801             * @param start the lower bound of the range of journal articles
5802             * @param end the upper bound of the range of journal articles (not inclusive)
5803             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5804             * @return the ordered range of matching journal articles
5805             * @throws SystemException if a system exception occurred
5806             */
5807            @Override
5808            public List<JournalArticle> findByR_I(long resourcePrimKey,
5809                    boolean indexable, int start, int end,
5810                    OrderByComparator orderByComparator) throws SystemException {
5811                    boolean pagination = true;
5812                    FinderPath finderPath = null;
5813                    Object[] finderArgs = null;
5814    
5815                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5816                                    (orderByComparator == null)) {
5817                            pagination = false;
5818                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I;
5819                            finderArgs = new Object[] { resourcePrimKey, indexable };
5820                    }
5821                    else {
5822                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I;
5823                            finderArgs = new Object[] {
5824                                            resourcePrimKey, indexable,
5825                                            
5826                                            start, end, orderByComparator
5827                                    };
5828                    }
5829    
5830                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5831                                    finderArgs, this);
5832    
5833                    if ((list != null) && !list.isEmpty()) {
5834                            for (JournalArticle journalArticle : list) {
5835                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5836                                                    (indexable != journalArticle.getIndexable())) {
5837                                            list = null;
5838    
5839                                            break;
5840                                    }
5841                            }
5842                    }
5843    
5844                    if (list == null) {
5845                            StringBundler query = null;
5846    
5847                            if (orderByComparator != null) {
5848                                    query = new StringBundler(4 +
5849                                                    (orderByComparator.getOrderByFields().length * 3));
5850                            }
5851                            else {
5852                                    query = new StringBundler(4);
5853                            }
5854    
5855                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5856    
5857                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5858    
5859                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5860    
5861                            if (orderByComparator != null) {
5862                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5863                                            orderByComparator);
5864                            }
5865                            else
5866                             if (pagination) {
5867                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5868                            }
5869    
5870                            String sql = query.toString();
5871    
5872                            Session session = null;
5873    
5874                            try {
5875                                    session = openSession();
5876    
5877                                    Query q = session.createQuery(sql);
5878    
5879                                    QueryPos qPos = QueryPos.getInstance(q);
5880    
5881                                    qPos.add(resourcePrimKey);
5882    
5883                                    qPos.add(indexable);
5884    
5885                                    if (!pagination) {
5886                                            list = (List<JournalArticle>)QueryUtil.list(q,
5887                                                            getDialect(), start, end, false);
5888    
5889                                            Collections.sort(list);
5890    
5891                                            list = new UnmodifiableList<JournalArticle>(list);
5892                                    }
5893                                    else {
5894                                            list = (List<JournalArticle>)QueryUtil.list(q,
5895                                                            getDialect(), start, end);
5896                                    }
5897    
5898                                    cacheResult(list);
5899    
5900                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5901                            }
5902                            catch (Exception e) {
5903                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5904    
5905                                    throw processException(e);
5906                            }
5907                            finally {
5908                                    closeSession(session);
5909                            }
5910                    }
5911    
5912                    return list;
5913            }
5914    
5915            /**
5916             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5917             *
5918             * @param resourcePrimKey the resource prim key
5919             * @param indexable the indexable
5920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5921             * @return the first matching journal article
5922             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5923             * @throws SystemException if a system exception occurred
5924             */
5925            @Override
5926            public JournalArticle findByR_I_First(long resourcePrimKey,
5927                    boolean indexable, OrderByComparator orderByComparator)
5928                    throws NoSuchArticleException, SystemException {
5929                    JournalArticle journalArticle = fetchByR_I_First(resourcePrimKey,
5930                                    indexable, orderByComparator);
5931    
5932                    if (journalArticle != null) {
5933                            return journalArticle;
5934                    }
5935    
5936                    StringBundler msg = new StringBundler(6);
5937    
5938                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5939    
5940                    msg.append("resourcePrimKey=");
5941                    msg.append(resourcePrimKey);
5942    
5943                    msg.append(", indexable=");
5944                    msg.append(indexable);
5945    
5946                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5947    
5948                    throw new NoSuchArticleException(msg.toString());
5949            }
5950    
5951            /**
5952             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5953             *
5954             * @param resourcePrimKey the resource prim key
5955             * @param indexable the indexable
5956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5957             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5958             * @throws SystemException if a system exception occurred
5959             */
5960            @Override
5961            public JournalArticle fetchByR_I_First(long resourcePrimKey,
5962                    boolean indexable, OrderByComparator orderByComparator)
5963                    throws SystemException {
5964                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable, 0, 1,
5965                                    orderByComparator);
5966    
5967                    if (!list.isEmpty()) {
5968                            return list.get(0);
5969                    }
5970    
5971                    return null;
5972            }
5973    
5974            /**
5975             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5976             *
5977             * @param resourcePrimKey the resource prim key
5978             * @param indexable the indexable
5979             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5980             * @return the last matching journal article
5981             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5982             * @throws SystemException if a system exception occurred
5983             */
5984            @Override
5985            public JournalArticle findByR_I_Last(long resourcePrimKey,
5986                    boolean indexable, OrderByComparator orderByComparator)
5987                    throws NoSuchArticleException, SystemException {
5988                    JournalArticle journalArticle = fetchByR_I_Last(resourcePrimKey,
5989                                    indexable, orderByComparator);
5990    
5991                    if (journalArticle != null) {
5992                            return journalArticle;
5993                    }
5994    
5995                    StringBundler msg = new StringBundler(6);
5996    
5997                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5998    
5999                    msg.append("resourcePrimKey=");
6000                    msg.append(resourcePrimKey);
6001    
6002                    msg.append(", indexable=");
6003                    msg.append(indexable);
6004    
6005                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6006    
6007                    throw new NoSuchArticleException(msg.toString());
6008            }
6009    
6010            /**
6011             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6012             *
6013             * @param resourcePrimKey the resource prim key
6014             * @param indexable the indexable
6015             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6016             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6017             * @throws SystemException if a system exception occurred
6018             */
6019            @Override
6020            public JournalArticle fetchByR_I_Last(long resourcePrimKey,
6021                    boolean indexable, OrderByComparator orderByComparator)
6022                    throws SystemException {
6023                    int count = countByR_I(resourcePrimKey, indexable);
6024    
6025                    if (count == 0) {
6026                            return null;
6027                    }
6028    
6029                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable,
6030                                    count - 1, count, orderByComparator);
6031    
6032                    if (!list.isEmpty()) {
6033                            return list.get(0);
6034                    }
6035    
6036                    return null;
6037            }
6038    
6039            /**
6040             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6041             *
6042             * @param id the primary key of the current journal article
6043             * @param resourcePrimKey the resource prim key
6044             * @param indexable the indexable
6045             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6046             * @return the previous, current, and next journal article
6047             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6048             * @throws SystemException if a system exception occurred
6049             */
6050            @Override
6051            public JournalArticle[] findByR_I_PrevAndNext(long id,
6052                    long resourcePrimKey, boolean indexable,
6053                    OrderByComparator orderByComparator)
6054                    throws NoSuchArticleException, SystemException {
6055                    JournalArticle journalArticle = findByPrimaryKey(id);
6056    
6057                    Session session = null;
6058    
6059                    try {
6060                            session = openSession();
6061    
6062                            JournalArticle[] array = new JournalArticleImpl[3];
6063    
6064                            array[0] = getByR_I_PrevAndNext(session, journalArticle,
6065                                            resourcePrimKey, indexable, orderByComparator, true);
6066    
6067                            array[1] = journalArticle;
6068    
6069                            array[2] = getByR_I_PrevAndNext(session, journalArticle,
6070                                            resourcePrimKey, indexable, orderByComparator, false);
6071    
6072                            return array;
6073                    }
6074                    catch (Exception e) {
6075                            throw processException(e);
6076                    }
6077                    finally {
6078                            closeSession(session);
6079                    }
6080            }
6081    
6082            protected JournalArticle getByR_I_PrevAndNext(Session session,
6083                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
6084                    OrderByComparator orderByComparator, boolean previous) {
6085                    StringBundler query = null;
6086    
6087                    if (orderByComparator != null) {
6088                            query = new StringBundler(6 +
6089                                            (orderByComparator.getOrderByFields().length * 6));
6090                    }
6091                    else {
6092                            query = new StringBundler(3);
6093                    }
6094    
6095                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6096    
6097                    query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6098    
6099                    query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6100    
6101                    if (orderByComparator != null) {
6102                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6103    
6104                            if (orderByConditionFields.length > 0) {
6105                                    query.append(WHERE_AND);
6106                            }
6107    
6108                            for (int i = 0; i < orderByConditionFields.length; i++) {
6109                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6110                                    query.append(orderByConditionFields[i]);
6111    
6112                                    if ((i + 1) < orderByConditionFields.length) {
6113                                            if (orderByComparator.isAscending() ^ previous) {
6114                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6115                                            }
6116                                            else {
6117                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6118                                            }
6119                                    }
6120                                    else {
6121                                            if (orderByComparator.isAscending() ^ previous) {
6122                                                    query.append(WHERE_GREATER_THAN);
6123                                            }
6124                                            else {
6125                                                    query.append(WHERE_LESSER_THAN);
6126                                            }
6127                                    }
6128                            }
6129    
6130                            query.append(ORDER_BY_CLAUSE);
6131    
6132                            String[] orderByFields = orderByComparator.getOrderByFields();
6133    
6134                            for (int i = 0; i < orderByFields.length; i++) {
6135                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6136                                    query.append(orderByFields[i]);
6137    
6138                                    if ((i + 1) < orderByFields.length) {
6139                                            if (orderByComparator.isAscending() ^ previous) {
6140                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6141                                            }
6142                                            else {
6143                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6144                                            }
6145                                    }
6146                                    else {
6147                                            if (orderByComparator.isAscending() ^ previous) {
6148                                                    query.append(ORDER_BY_ASC);
6149                                            }
6150                                            else {
6151                                                    query.append(ORDER_BY_DESC);
6152                                            }
6153                                    }
6154                            }
6155                    }
6156                    else {
6157                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6158                    }
6159    
6160                    String sql = query.toString();
6161    
6162                    Query q = session.createQuery(sql);
6163    
6164                    q.setFirstResult(0);
6165                    q.setMaxResults(2);
6166    
6167                    QueryPos qPos = QueryPos.getInstance(q);
6168    
6169                    qPos.add(resourcePrimKey);
6170    
6171                    qPos.add(indexable);
6172    
6173                    if (orderByComparator != null) {
6174                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6175    
6176                            for (Object value : values) {
6177                                    qPos.add(value);
6178                            }
6179                    }
6180    
6181                    List<JournalArticle> list = q.list();
6182    
6183                    if (list.size() == 2) {
6184                            return list.get(1);
6185                    }
6186                    else {
6187                            return null;
6188                    }
6189            }
6190    
6191            /**
6192             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; from the database.
6193             *
6194             * @param resourcePrimKey the resource prim key
6195             * @param indexable the indexable
6196             * @throws SystemException if a system exception occurred
6197             */
6198            @Override
6199            public void removeByR_I(long resourcePrimKey, boolean indexable)
6200                    throws SystemException {
6201                    for (JournalArticle journalArticle : findByR_I(resourcePrimKey,
6202                                    indexable, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6203                            remove(journalArticle);
6204                    }
6205            }
6206    
6207            /**
6208             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63;.
6209             *
6210             * @param resourcePrimKey the resource prim key
6211             * @param indexable the indexable
6212             * @return the number of matching journal articles
6213             * @throws SystemException if a system exception occurred
6214             */
6215            @Override
6216            public int countByR_I(long resourcePrimKey, boolean indexable)
6217                    throws SystemException {
6218                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I;
6219    
6220                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable };
6221    
6222                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6223                                    this);
6224    
6225                    if (count == null) {
6226                            StringBundler query = new StringBundler(3);
6227    
6228                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6229    
6230                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6231    
6232                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6233    
6234                            String sql = query.toString();
6235    
6236                            Session session = null;
6237    
6238                            try {
6239                                    session = openSession();
6240    
6241                                    Query q = session.createQuery(sql);
6242    
6243                                    QueryPos qPos = QueryPos.getInstance(q);
6244    
6245                                    qPos.add(resourcePrimKey);
6246    
6247                                    qPos.add(indexable);
6248    
6249                                    count = (Long)q.uniqueResult();
6250    
6251                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6252                            }
6253                            catch (Exception e) {
6254                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6255    
6256                                    throw processException(e);
6257                            }
6258                            finally {
6259                                    closeSession(session);
6260                            }
6261                    }
6262    
6263                    return count.intValue();
6264            }
6265    
6266            private static final String _FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6267            private static final String _FINDER_COLUMN_R_I_INDEXABLE_2 = "journalArticle.indexable = ?";
6268            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6269                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6270                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6271                            "findByR_ST",
6272                            new String[] {
6273                                    Long.class.getName(), Integer.class.getName(),
6274                                    
6275                            Integer.class.getName(), Integer.class.getName(),
6276                                    OrderByComparator.class.getName()
6277                            });
6278            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6279                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6280                            JournalArticleImpl.class,
6281                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
6282                            new String[] { Long.class.getName(), Integer.class.getName() },
6283                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6284                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
6285                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6286                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6287            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6288                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6289                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
6290                            new String[] { Long.class.getName(), Integer.class.getName() });
6291            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6292                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6293                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_ST",
6294                            new String[] { Long.class.getName(), Integer.class.getName() });
6295    
6296            /**
6297             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6298             *
6299             * @param resourcePrimKey the resource prim key
6300             * @param status the status
6301             * @return the matching journal articles
6302             * @throws SystemException if a system exception occurred
6303             */
6304            @Override
6305            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
6306                    throws SystemException {
6307                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
6308                            QueryUtil.ALL_POS, null);
6309            }
6310    
6311            /**
6312             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6313             *
6314             * <p>
6315             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6316             * </p>
6317             *
6318             * @param resourcePrimKey the resource prim key
6319             * @param status the status
6320             * @param start the lower bound of the range of journal articles
6321             * @param end the upper bound of the range of journal articles (not inclusive)
6322             * @return the range of matching journal articles
6323             * @throws SystemException if a system exception occurred
6324             */
6325            @Override
6326            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6327                    int start, int end) throws SystemException {
6328                    return findByR_ST(resourcePrimKey, status, start, end, null);
6329            }
6330    
6331            /**
6332             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6333             *
6334             * <p>
6335             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6336             * </p>
6337             *
6338             * @param resourcePrimKey the resource prim key
6339             * @param status the status
6340             * @param start the lower bound of the range of journal articles
6341             * @param end the upper bound of the range of journal articles (not inclusive)
6342             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6343             * @return the ordered range of matching journal articles
6344             * @throws SystemException if a system exception occurred
6345             */
6346            @Override
6347            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6348                    int start, int end, OrderByComparator orderByComparator)
6349                    throws SystemException {
6350                    boolean pagination = true;
6351                    FinderPath finderPath = null;
6352                    Object[] finderArgs = null;
6353    
6354                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6355                                    (orderByComparator == null)) {
6356                            pagination = false;
6357                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
6358                            finderArgs = new Object[] { resourcePrimKey, status };
6359                    }
6360                    else {
6361                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
6362                            finderArgs = new Object[] {
6363                                            resourcePrimKey, status,
6364                                            
6365                                            start, end, orderByComparator
6366                                    };
6367                    }
6368    
6369                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6370                                    finderArgs, this);
6371    
6372                    if ((list != null) && !list.isEmpty()) {
6373                            for (JournalArticle journalArticle : list) {
6374                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6375                                                    (status != journalArticle.getStatus())) {
6376                                            list = null;
6377    
6378                                            break;
6379                                    }
6380                            }
6381                    }
6382    
6383                    if (list == null) {
6384                            StringBundler query = null;
6385    
6386                            if (orderByComparator != null) {
6387                                    query = new StringBundler(4 +
6388                                                    (orderByComparator.getOrderByFields().length * 3));
6389                            }
6390                            else {
6391                                    query = new StringBundler(4);
6392                            }
6393    
6394                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6395    
6396                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6397    
6398                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6399    
6400                            if (orderByComparator != null) {
6401                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6402                                            orderByComparator);
6403                            }
6404                            else
6405                             if (pagination) {
6406                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6407                            }
6408    
6409                            String sql = query.toString();
6410    
6411                            Session session = null;
6412    
6413                            try {
6414                                    session = openSession();
6415    
6416                                    Query q = session.createQuery(sql);
6417    
6418                                    QueryPos qPos = QueryPos.getInstance(q);
6419    
6420                                    qPos.add(resourcePrimKey);
6421    
6422                                    qPos.add(status);
6423    
6424                                    if (!pagination) {
6425                                            list = (List<JournalArticle>)QueryUtil.list(q,
6426                                                            getDialect(), start, end, false);
6427    
6428                                            Collections.sort(list);
6429    
6430                                            list = new UnmodifiableList<JournalArticle>(list);
6431                                    }
6432                                    else {
6433                                            list = (List<JournalArticle>)QueryUtil.list(q,
6434                                                            getDialect(), start, end);
6435                                    }
6436    
6437                                    cacheResult(list);
6438    
6439                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6440                            }
6441                            catch (Exception e) {
6442                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6443    
6444                                    throw processException(e);
6445                            }
6446                            finally {
6447                                    closeSession(session);
6448                            }
6449                    }
6450    
6451                    return list;
6452            }
6453    
6454            /**
6455             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6456             *
6457             * @param resourcePrimKey the resource prim key
6458             * @param status the status
6459             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6460             * @return the first matching journal article
6461             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6462             * @throws SystemException if a system exception occurred
6463             */
6464            @Override
6465            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
6466                    OrderByComparator orderByComparator)
6467                    throws NoSuchArticleException, SystemException {
6468                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
6469                                    status, orderByComparator);
6470    
6471                    if (journalArticle != null) {
6472                            return journalArticle;
6473                    }
6474    
6475                    StringBundler msg = new StringBundler(6);
6476    
6477                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6478    
6479                    msg.append("resourcePrimKey=");
6480                    msg.append(resourcePrimKey);
6481    
6482                    msg.append(", status=");
6483                    msg.append(status);
6484    
6485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6486    
6487                    throw new NoSuchArticleException(msg.toString());
6488            }
6489    
6490            /**
6491             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6492             *
6493             * @param resourcePrimKey the resource prim key
6494             * @param status the status
6495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6496             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6497             * @throws SystemException if a system exception occurred
6498             */
6499            @Override
6500            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
6501                    OrderByComparator orderByComparator) throws SystemException {
6502                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
6503                                    orderByComparator);
6504    
6505                    if (!list.isEmpty()) {
6506                            return list.get(0);
6507                    }
6508    
6509                    return null;
6510            }
6511    
6512            /**
6513             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6514             *
6515             * @param resourcePrimKey the resource prim key
6516             * @param status the status
6517             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6518             * @return the last matching journal article
6519             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6520             * @throws SystemException if a system exception occurred
6521             */
6522            @Override
6523            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
6524                    OrderByComparator orderByComparator)
6525                    throws NoSuchArticleException, SystemException {
6526                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
6527                                    status, orderByComparator);
6528    
6529                    if (journalArticle != null) {
6530                            return journalArticle;
6531                    }
6532    
6533                    StringBundler msg = new StringBundler(6);
6534    
6535                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6536    
6537                    msg.append("resourcePrimKey=");
6538                    msg.append(resourcePrimKey);
6539    
6540                    msg.append(", status=");
6541                    msg.append(status);
6542    
6543                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6544    
6545                    throw new NoSuchArticleException(msg.toString());
6546            }
6547    
6548            /**
6549             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6550             *
6551             * @param resourcePrimKey the resource prim key
6552             * @param status the status
6553             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6554             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6555             * @throws SystemException if a system exception occurred
6556             */
6557            @Override
6558            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6559                    OrderByComparator orderByComparator) throws SystemException {
6560                    int count = countByR_ST(resourcePrimKey, status);
6561    
6562                    if (count == 0) {
6563                            return null;
6564                    }
6565    
6566                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6567                                    count - 1, count, orderByComparator);
6568    
6569                    if (!list.isEmpty()) {
6570                            return list.get(0);
6571                    }
6572    
6573                    return null;
6574            }
6575    
6576            /**
6577             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6578             *
6579             * @param id the primary key of the current journal article
6580             * @param resourcePrimKey the resource prim key
6581             * @param status the status
6582             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6583             * @return the previous, current, and next journal article
6584             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6585             * @throws SystemException if a system exception occurred
6586             */
6587            @Override
6588            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6589                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
6590                    throws NoSuchArticleException, SystemException {
6591                    JournalArticle journalArticle = findByPrimaryKey(id);
6592    
6593                    Session session = null;
6594    
6595                    try {
6596                            session = openSession();
6597    
6598                            JournalArticle[] array = new JournalArticleImpl[3];
6599    
6600                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6601                                            resourcePrimKey, status, orderByComparator, true);
6602    
6603                            array[1] = journalArticle;
6604    
6605                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6606                                            resourcePrimKey, status, orderByComparator, false);
6607    
6608                            return array;
6609                    }
6610                    catch (Exception e) {
6611                            throw processException(e);
6612                    }
6613                    finally {
6614                            closeSession(session);
6615                    }
6616            }
6617    
6618            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6619                    JournalArticle journalArticle, long resourcePrimKey, int status,
6620                    OrderByComparator orderByComparator, boolean previous) {
6621                    StringBundler query = null;
6622    
6623                    if (orderByComparator != null) {
6624                            query = new StringBundler(6 +
6625                                            (orderByComparator.getOrderByFields().length * 6));
6626                    }
6627                    else {
6628                            query = new StringBundler(3);
6629                    }
6630    
6631                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6632    
6633                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6634    
6635                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6636    
6637                    if (orderByComparator != null) {
6638                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6639    
6640                            if (orderByConditionFields.length > 0) {
6641                                    query.append(WHERE_AND);
6642                            }
6643    
6644                            for (int i = 0; i < orderByConditionFields.length; i++) {
6645                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6646                                    query.append(orderByConditionFields[i]);
6647    
6648                                    if ((i + 1) < orderByConditionFields.length) {
6649                                            if (orderByComparator.isAscending() ^ previous) {
6650                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6651                                            }
6652                                            else {
6653                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6654                                            }
6655                                    }
6656                                    else {
6657                                            if (orderByComparator.isAscending() ^ previous) {
6658                                                    query.append(WHERE_GREATER_THAN);
6659                                            }
6660                                            else {
6661                                                    query.append(WHERE_LESSER_THAN);
6662                                            }
6663                                    }
6664                            }
6665    
6666                            query.append(ORDER_BY_CLAUSE);
6667    
6668                            String[] orderByFields = orderByComparator.getOrderByFields();
6669    
6670                            for (int i = 0; i < orderByFields.length; i++) {
6671                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6672                                    query.append(orderByFields[i]);
6673    
6674                                    if ((i + 1) < orderByFields.length) {
6675                                            if (orderByComparator.isAscending() ^ previous) {
6676                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6677                                            }
6678                                            else {
6679                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6680                                            }
6681                                    }
6682                                    else {
6683                                            if (orderByComparator.isAscending() ^ previous) {
6684                                                    query.append(ORDER_BY_ASC);
6685                                            }
6686                                            else {
6687                                                    query.append(ORDER_BY_DESC);
6688                                            }
6689                                    }
6690                            }
6691                    }
6692                    else {
6693                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6694                    }
6695    
6696                    String sql = query.toString();
6697    
6698                    Query q = session.createQuery(sql);
6699    
6700                    q.setFirstResult(0);
6701                    q.setMaxResults(2);
6702    
6703                    QueryPos qPos = QueryPos.getInstance(q);
6704    
6705                    qPos.add(resourcePrimKey);
6706    
6707                    qPos.add(status);
6708    
6709                    if (orderByComparator != null) {
6710                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6711    
6712                            for (Object value : values) {
6713                                    qPos.add(value);
6714                            }
6715                    }
6716    
6717                    List<JournalArticle> list = q.list();
6718    
6719                    if (list.size() == 2) {
6720                            return list.get(1);
6721                    }
6722                    else {
6723                            return null;
6724                    }
6725            }
6726    
6727            /**
6728             * Returns all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6729             *
6730             * <p>
6731             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6732             * </p>
6733             *
6734             * @param resourcePrimKey the resource prim key
6735             * @param statuses the statuses
6736             * @return the matching journal articles
6737             * @throws SystemException if a system exception occurred
6738             */
6739            @Override
6740            public List<JournalArticle> findByR_ST(long resourcePrimKey, int[] statuses)
6741                    throws SystemException {
6742                    return findByR_ST(resourcePrimKey, statuses, QueryUtil.ALL_POS,
6743                            QueryUtil.ALL_POS, null);
6744            }
6745    
6746            /**
6747             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6748             *
6749             * <p>
6750             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6751             * </p>
6752             *
6753             * @param resourcePrimKey the resource prim key
6754             * @param statuses the statuses
6755             * @param start the lower bound of the range of journal articles
6756             * @param end the upper bound of the range of journal articles (not inclusive)
6757             * @return the range of matching journal articles
6758             * @throws SystemException if a system exception occurred
6759             */
6760            @Override
6761            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6762                    int[] statuses, int start, int end) throws SystemException {
6763                    return findByR_ST(resourcePrimKey, statuses, start, end, null);
6764            }
6765    
6766            /**
6767             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6768             *
6769             * <p>
6770             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6771             * </p>
6772             *
6773             * @param resourcePrimKey the resource prim key
6774             * @param statuses the statuses
6775             * @param start the lower bound of the range of journal articles
6776             * @param end the upper bound of the range of journal articles (not inclusive)
6777             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6778             * @return the ordered range of matching journal articles
6779             * @throws SystemException if a system exception occurred
6780             */
6781            @Override
6782            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6783                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
6784                    throws SystemException {
6785                    if ((statuses != null) && (statuses.length == 1)) {
6786                            return findByR_ST(resourcePrimKey, statuses[0], start, end,
6787                                    orderByComparator);
6788                    }
6789    
6790                    boolean pagination = true;
6791                    Object[] finderArgs = null;
6792    
6793                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6794                                    (orderByComparator == null)) {
6795                            pagination = false;
6796                            finderArgs = new Object[] {
6797                                            resourcePrimKey, StringUtil.merge(statuses)
6798                                    };
6799                    }
6800                    else {
6801                            finderArgs = new Object[] {
6802                                            resourcePrimKey, StringUtil.merge(statuses),
6803                                            
6804                                            start, end, orderByComparator
6805                                    };
6806                    }
6807    
6808                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6809                                    finderArgs, this);
6810    
6811                    if ((list != null) && !list.isEmpty()) {
6812                            for (JournalArticle journalArticle : list) {
6813                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6814                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
6815                                            list = null;
6816    
6817                                            break;
6818                                    }
6819                            }
6820                    }
6821    
6822                    if (list == null) {
6823                            StringBundler query = new StringBundler();
6824    
6825                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6826    
6827                            boolean conjunctionable = false;
6828    
6829                            if (conjunctionable) {
6830                                    query.append(WHERE_AND);
6831                            }
6832    
6833                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5);
6834    
6835                            conjunctionable = true;
6836    
6837                            if ((statuses == null) || (statuses.length > 0)) {
6838                                    if (conjunctionable) {
6839                                            query.append(WHERE_AND);
6840                                    }
6841    
6842                                    query.append(StringPool.OPEN_PARENTHESIS);
6843    
6844                                    for (int i = 0; i < statuses.length; i++) {
6845                                            query.append(_FINDER_COLUMN_R_ST_STATUS_5);
6846    
6847                                            if ((i + 1) < statuses.length) {
6848                                                    query.append(WHERE_OR);
6849                                            }
6850                                    }
6851    
6852                                    query.append(StringPool.CLOSE_PARENTHESIS);
6853    
6854                                    conjunctionable = true;
6855                            }
6856    
6857                            if (orderByComparator != null) {
6858                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6859                                            orderByComparator);
6860                            }
6861                            else
6862                             if (pagination) {
6863                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6864                            }
6865    
6866                            String sql = query.toString();
6867    
6868                            Session session = null;
6869    
6870                            try {
6871                                    session = openSession();
6872    
6873                                    Query q = session.createQuery(sql);
6874    
6875                                    QueryPos qPos = QueryPos.getInstance(q);
6876    
6877                                    qPos.add(resourcePrimKey);
6878    
6879                                    if (statuses != null) {
6880                                            qPos.add(statuses);
6881                                    }
6882    
6883                                    if (!pagination) {
6884                                            list = (List<JournalArticle>)QueryUtil.list(q,
6885                                                            getDialect(), start, end, false);
6886    
6887                                            Collections.sort(list);
6888    
6889                                            list = new UnmodifiableList<JournalArticle>(list);
6890                                    }
6891                                    else {
6892                                            list = (List<JournalArticle>)QueryUtil.list(q,
6893                                                            getDialect(), start, end);
6894                                    }
6895    
6896                                    cacheResult(list);
6897    
6898                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6899                                            finderArgs, list);
6900                            }
6901                            catch (Exception e) {
6902                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6903                                            finderArgs);
6904    
6905                                    throw processException(e);
6906                            }
6907                            finally {
6908                                    closeSession(session);
6909                            }
6910                    }
6911    
6912                    return list;
6913            }
6914    
6915            /**
6916             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6917             *
6918             * @param resourcePrimKey the resource prim key
6919             * @param status the status
6920             * @throws SystemException if a system exception occurred
6921             */
6922            @Override
6923            public void removeByR_ST(long resourcePrimKey, int status)
6924                    throws SystemException {
6925                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6926                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6927                            remove(journalArticle);
6928                    }
6929            }
6930    
6931            /**
6932             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6933             *
6934             * @param resourcePrimKey the resource prim key
6935             * @param status the status
6936             * @return the number of matching journal articles
6937             * @throws SystemException if a system exception occurred
6938             */
6939            @Override
6940            public int countByR_ST(long resourcePrimKey, int status)
6941                    throws SystemException {
6942                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6943    
6944                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6945    
6946                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6947                                    this);
6948    
6949                    if (count == null) {
6950                            StringBundler query = new StringBundler(3);
6951    
6952                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6953    
6954                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6955    
6956                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6957    
6958                            String sql = query.toString();
6959    
6960                            Session session = null;
6961    
6962                            try {
6963                                    session = openSession();
6964    
6965                                    Query q = session.createQuery(sql);
6966    
6967                                    QueryPos qPos = QueryPos.getInstance(q);
6968    
6969                                    qPos.add(resourcePrimKey);
6970    
6971                                    qPos.add(status);
6972    
6973                                    count = (Long)q.uniqueResult();
6974    
6975                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6976                            }
6977                            catch (Exception e) {
6978                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6979    
6980                                    throw processException(e);
6981                            }
6982                            finally {
6983                                    closeSession(session);
6984                            }
6985                    }
6986    
6987                    return count.intValue();
6988            }
6989    
6990            /**
6991             * Returns the number of journal articles where resourcePrimKey = &#63; and status = any &#63;.
6992             *
6993             * @param resourcePrimKey the resource prim key
6994             * @param statuses the statuses
6995             * @return the number of matching journal articles
6996             * @throws SystemException if a system exception occurred
6997             */
6998            @Override
6999            public int countByR_ST(long resourcePrimKey, int[] statuses)
7000                    throws SystemException {
7001                    Object[] finderArgs = new Object[] {
7002                                    resourcePrimKey, StringUtil.merge(statuses)
7003                            };
7004    
7005                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7006                                    finderArgs, this);
7007    
7008                    if (count == null) {
7009                            StringBundler query = new StringBundler();
7010    
7011                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7012    
7013                            boolean conjunctionable = false;
7014    
7015                            if (conjunctionable) {
7016                                    query.append(WHERE_AND);
7017                            }
7018    
7019                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5);
7020    
7021                            conjunctionable = true;
7022    
7023                            if ((statuses == null) || (statuses.length > 0)) {
7024                                    if (conjunctionable) {
7025                                            query.append(WHERE_AND);
7026                                    }
7027    
7028                                    query.append(StringPool.OPEN_PARENTHESIS);
7029    
7030                                    for (int i = 0; i < statuses.length; i++) {
7031                                            query.append(_FINDER_COLUMN_R_ST_STATUS_5);
7032    
7033                                            if ((i + 1) < statuses.length) {
7034                                                    query.append(WHERE_OR);
7035                                            }
7036                                    }
7037    
7038                                    query.append(StringPool.CLOSE_PARENTHESIS);
7039    
7040                                    conjunctionable = true;
7041                            }
7042    
7043                            String sql = query.toString();
7044    
7045                            Session session = null;
7046    
7047                            try {
7048                                    session = openSession();
7049    
7050                                    Query q = session.createQuery(sql);
7051    
7052                                    QueryPos qPos = QueryPos.getInstance(q);
7053    
7054                                    qPos.add(resourcePrimKey);
7055    
7056                                    if (statuses != null) {
7057                                            qPos.add(statuses);
7058                                    }
7059    
7060                                    count = (Long)q.uniqueResult();
7061    
7062                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7063                                            finderArgs, count);
7064                            }
7065                            catch (Exception e) {
7066                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7067                                            finderArgs);
7068    
7069                                    throw processException(e);
7070                            }
7071                            finally {
7072                                    closeSession(session);
7073                            }
7074                    }
7075    
7076                    return count.intValue();
7077            }
7078    
7079            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
7080            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5 = "(" +
7081                    removeConjunction(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2) + ")";
7082            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
7083            private static final String _FINDER_COLUMN_R_ST_STATUS_5 = "(" +
7084                    removeConjunction(_FINDER_COLUMN_R_ST_STATUS_2) + ")";
7085            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7086                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7087                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7088                            "findByG_U",
7089                            new String[] {
7090                                    Long.class.getName(), Long.class.getName(),
7091                                    
7092                            Integer.class.getName(), Integer.class.getName(),
7093                                    OrderByComparator.class.getName()
7094                            });
7095            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7096                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7097                            JournalArticleImpl.class,
7098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
7099                            new String[] { Long.class.getName(), Long.class.getName() },
7100                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7101                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
7102                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7103                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7104            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7105                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
7107                            new String[] { Long.class.getName(), Long.class.getName() });
7108    
7109            /**
7110             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
7111             *
7112             * @param groupId the group ID
7113             * @param userId the user ID
7114             * @return the matching journal articles
7115             * @throws SystemException if a system exception occurred
7116             */
7117            @Override
7118            public List<JournalArticle> findByG_U(long groupId, long userId)
7119                    throws SystemException {
7120                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7121                            null);
7122            }
7123    
7124            /**
7125             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
7126             *
7127             * <p>
7128             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7129             * </p>
7130             *
7131             * @param groupId the group ID
7132             * @param userId the user ID
7133             * @param start the lower bound of the range of journal articles
7134             * @param end the upper bound of the range of journal articles (not inclusive)
7135             * @return the range of matching journal articles
7136             * @throws SystemException if a system exception occurred
7137             */
7138            @Override
7139            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
7140                    int end) throws SystemException {
7141                    return findByG_U(groupId, userId, start, end, null);
7142            }
7143    
7144            /**
7145             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
7146             *
7147             * <p>
7148             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7149             * </p>
7150             *
7151             * @param groupId the group ID
7152             * @param userId the user ID
7153             * @param start the lower bound of the range of journal articles
7154             * @param end the upper bound of the range of journal articles (not inclusive)
7155             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7156             * @return the ordered range of matching journal articles
7157             * @throws SystemException if a system exception occurred
7158             */
7159            @Override
7160            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
7161                    int end, OrderByComparator orderByComparator) throws SystemException {
7162                    boolean pagination = true;
7163                    FinderPath finderPath = null;
7164                    Object[] finderArgs = null;
7165    
7166                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7167                                    (orderByComparator == null)) {
7168                            pagination = false;
7169                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
7170                            finderArgs = new Object[] { groupId, userId };
7171                    }
7172                    else {
7173                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
7174                            finderArgs = new Object[] {
7175                                            groupId, userId,
7176                                            
7177                                            start, end, orderByComparator
7178                                    };
7179                    }
7180    
7181                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7182                                    finderArgs, this);
7183    
7184                    if ((list != null) && !list.isEmpty()) {
7185                            for (JournalArticle journalArticle : list) {
7186                                    if ((groupId != journalArticle.getGroupId()) ||
7187                                                    (userId != journalArticle.getUserId())) {
7188                                            list = null;
7189    
7190                                            break;
7191                                    }
7192                            }
7193                    }
7194    
7195                    if (list == null) {
7196                            StringBundler query = null;
7197    
7198                            if (orderByComparator != null) {
7199                                    query = new StringBundler(4 +
7200                                                    (orderByComparator.getOrderByFields().length * 3));
7201                            }
7202                            else {
7203                                    query = new StringBundler(4);
7204                            }
7205    
7206                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7207    
7208                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7209    
7210                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7211    
7212                            if (orderByComparator != null) {
7213                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7214                                            orderByComparator);
7215                            }
7216                            else
7217                             if (pagination) {
7218                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7219                            }
7220    
7221                            String sql = query.toString();
7222    
7223                            Session session = null;
7224    
7225                            try {
7226                                    session = openSession();
7227    
7228                                    Query q = session.createQuery(sql);
7229    
7230                                    QueryPos qPos = QueryPos.getInstance(q);
7231    
7232                                    qPos.add(groupId);
7233    
7234                                    qPos.add(userId);
7235    
7236                                    if (!pagination) {
7237                                            list = (List<JournalArticle>)QueryUtil.list(q,
7238                                                            getDialect(), start, end, false);
7239    
7240                                            Collections.sort(list);
7241    
7242                                            list = new UnmodifiableList<JournalArticle>(list);
7243                                    }
7244                                    else {
7245                                            list = (List<JournalArticle>)QueryUtil.list(q,
7246                                                            getDialect(), start, end);
7247                                    }
7248    
7249                                    cacheResult(list);
7250    
7251                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7252                            }
7253                            catch (Exception e) {
7254                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7255    
7256                                    throw processException(e);
7257                            }
7258                            finally {
7259                                    closeSession(session);
7260                            }
7261                    }
7262    
7263                    return list;
7264            }
7265    
7266            /**
7267             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7268             *
7269             * @param groupId the group ID
7270             * @param userId the user ID
7271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7272             * @return the first matching journal article
7273             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7274             * @throws SystemException if a system exception occurred
7275             */
7276            @Override
7277            public JournalArticle findByG_U_First(long groupId, long userId,
7278                    OrderByComparator orderByComparator)
7279                    throws NoSuchArticleException, SystemException {
7280                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
7281                                    orderByComparator);
7282    
7283                    if (journalArticle != null) {
7284                            return journalArticle;
7285                    }
7286    
7287                    StringBundler msg = new StringBundler(6);
7288    
7289                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7290    
7291                    msg.append("groupId=");
7292                    msg.append(groupId);
7293    
7294                    msg.append(", userId=");
7295                    msg.append(userId);
7296    
7297                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7298    
7299                    throw new NoSuchArticleException(msg.toString());
7300            }
7301    
7302            /**
7303             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7304             *
7305             * @param groupId the group ID
7306             * @param userId the user ID
7307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7308             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7309             * @throws SystemException if a system exception occurred
7310             */
7311            @Override
7312            public JournalArticle fetchByG_U_First(long groupId, long userId,
7313                    OrderByComparator orderByComparator) throws SystemException {
7314                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
7315                                    orderByComparator);
7316    
7317                    if (!list.isEmpty()) {
7318                            return list.get(0);
7319                    }
7320    
7321                    return null;
7322            }
7323    
7324            /**
7325             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7326             *
7327             * @param groupId the group ID
7328             * @param userId the user ID
7329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7330             * @return the last matching journal article
7331             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7332             * @throws SystemException if a system exception occurred
7333             */
7334            @Override
7335            public JournalArticle findByG_U_Last(long groupId, long userId,
7336                    OrderByComparator orderByComparator)
7337                    throws NoSuchArticleException, SystemException {
7338                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
7339                                    orderByComparator);
7340    
7341                    if (journalArticle != null) {
7342                            return journalArticle;
7343                    }
7344    
7345                    StringBundler msg = new StringBundler(6);
7346    
7347                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7348    
7349                    msg.append("groupId=");
7350                    msg.append(groupId);
7351    
7352                    msg.append(", userId=");
7353                    msg.append(userId);
7354    
7355                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7356    
7357                    throw new NoSuchArticleException(msg.toString());
7358            }
7359    
7360            /**
7361             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7362             *
7363             * @param groupId the group ID
7364             * @param userId the user ID
7365             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7366             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7367             * @throws SystemException if a system exception occurred
7368             */
7369            @Override
7370            public JournalArticle fetchByG_U_Last(long groupId, long userId,
7371                    OrderByComparator orderByComparator) throws SystemException {
7372                    int count = countByG_U(groupId, userId);
7373    
7374                    if (count == 0) {
7375                            return null;
7376                    }
7377    
7378                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
7379                                    count, orderByComparator);
7380    
7381                    if (!list.isEmpty()) {
7382                            return list.get(0);
7383                    }
7384    
7385                    return null;
7386            }
7387    
7388            /**
7389             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
7390             *
7391             * @param id the primary key of the current journal article
7392             * @param groupId the group ID
7393             * @param userId the user ID
7394             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7395             * @return the previous, current, and next journal article
7396             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7397             * @throws SystemException if a system exception occurred
7398             */
7399            @Override
7400            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
7401                    long userId, OrderByComparator orderByComparator)
7402                    throws NoSuchArticleException, SystemException {
7403                    JournalArticle journalArticle = findByPrimaryKey(id);
7404    
7405                    Session session = null;
7406    
7407                    try {
7408                            session = openSession();
7409    
7410                            JournalArticle[] array = new JournalArticleImpl[3];
7411    
7412                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7413                                            userId, orderByComparator, true);
7414    
7415                            array[1] = journalArticle;
7416    
7417                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7418                                            userId, orderByComparator, false);
7419    
7420                            return array;
7421                    }
7422                    catch (Exception e) {
7423                            throw processException(e);
7424                    }
7425                    finally {
7426                            closeSession(session);
7427                    }
7428            }
7429    
7430            protected JournalArticle getByG_U_PrevAndNext(Session session,
7431                    JournalArticle journalArticle, long groupId, long userId,
7432                    OrderByComparator orderByComparator, boolean previous) {
7433                    StringBundler query = null;
7434    
7435                    if (orderByComparator != null) {
7436                            query = new StringBundler(6 +
7437                                            (orderByComparator.getOrderByFields().length * 6));
7438                    }
7439                    else {
7440                            query = new StringBundler(3);
7441                    }
7442    
7443                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7444    
7445                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7446    
7447                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7448    
7449                    if (orderByComparator != null) {
7450                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7451    
7452                            if (orderByConditionFields.length > 0) {
7453                                    query.append(WHERE_AND);
7454                            }
7455    
7456                            for (int i = 0; i < orderByConditionFields.length; i++) {
7457                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7458                                    query.append(orderByConditionFields[i]);
7459    
7460                                    if ((i + 1) < orderByConditionFields.length) {
7461                                            if (orderByComparator.isAscending() ^ previous) {
7462                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7463                                            }
7464                                            else {
7465                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7466                                            }
7467                                    }
7468                                    else {
7469                                            if (orderByComparator.isAscending() ^ previous) {
7470                                                    query.append(WHERE_GREATER_THAN);
7471                                            }
7472                                            else {
7473                                                    query.append(WHERE_LESSER_THAN);
7474                                            }
7475                                    }
7476                            }
7477    
7478                            query.append(ORDER_BY_CLAUSE);
7479    
7480                            String[] orderByFields = orderByComparator.getOrderByFields();
7481    
7482                            for (int i = 0; i < orderByFields.length; i++) {
7483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7484                                    query.append(orderByFields[i]);
7485    
7486                                    if ((i + 1) < orderByFields.length) {
7487                                            if (orderByComparator.isAscending() ^ previous) {
7488                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7489                                            }
7490                                            else {
7491                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7492                                            }
7493                                    }
7494                                    else {
7495                                            if (orderByComparator.isAscending() ^ previous) {
7496                                                    query.append(ORDER_BY_ASC);
7497                                            }
7498                                            else {
7499                                                    query.append(ORDER_BY_DESC);
7500                                            }
7501                                    }
7502                            }
7503                    }
7504                    else {
7505                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7506                    }
7507    
7508                    String sql = query.toString();
7509    
7510                    Query q = session.createQuery(sql);
7511    
7512                    q.setFirstResult(0);
7513                    q.setMaxResults(2);
7514    
7515                    QueryPos qPos = QueryPos.getInstance(q);
7516    
7517                    qPos.add(groupId);
7518    
7519                    qPos.add(userId);
7520    
7521                    if (orderByComparator != null) {
7522                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7523    
7524                            for (Object value : values) {
7525                                    qPos.add(value);
7526                            }
7527                    }
7528    
7529                    List<JournalArticle> list = q.list();
7530    
7531                    if (list.size() == 2) {
7532                            return list.get(1);
7533                    }
7534                    else {
7535                            return null;
7536                    }
7537            }
7538    
7539            /**
7540             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7541             *
7542             * @param groupId the group ID
7543             * @param userId the user ID
7544             * @return the matching journal articles that the user has permission to view
7545             * @throws SystemException if a system exception occurred
7546             */
7547            @Override
7548            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
7549                    throws SystemException {
7550                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
7551                            QueryUtil.ALL_POS, null);
7552            }
7553    
7554            /**
7555             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7556             *
7557             * <p>
7558             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7559             * </p>
7560             *
7561             * @param groupId the group ID
7562             * @param userId the user ID
7563             * @param start the lower bound of the range of journal articles
7564             * @param end the upper bound of the range of journal articles (not inclusive)
7565             * @return the range of matching journal articles that the user has permission to view
7566             * @throws SystemException if a system exception occurred
7567             */
7568            @Override
7569            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7570                    int start, int end) throws SystemException {
7571                    return filterFindByG_U(groupId, userId, start, end, null);
7572            }
7573    
7574            /**
7575             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
7576             *
7577             * <p>
7578             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7579             * </p>
7580             *
7581             * @param groupId the group ID
7582             * @param userId the user ID
7583             * @param start the lower bound of the range of journal articles
7584             * @param end the upper bound of the range of journal articles (not inclusive)
7585             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7586             * @return the ordered range of matching journal articles that the user has permission to view
7587             * @throws SystemException if a system exception occurred
7588             */
7589            @Override
7590            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7591                    int start, int end, OrderByComparator orderByComparator)
7592                    throws SystemException {
7593                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7594                            return findByG_U(groupId, userId, start, end, orderByComparator);
7595                    }
7596    
7597                    StringBundler query = null;
7598    
7599                    if (orderByComparator != null) {
7600                            query = new StringBundler(4 +
7601                                            (orderByComparator.getOrderByFields().length * 3));
7602                    }
7603                    else {
7604                            query = new StringBundler(4);
7605                    }
7606    
7607                    if (getDB().isSupportsInlineDistinct()) {
7608                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7609                    }
7610                    else {
7611                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7612                    }
7613    
7614                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7615    
7616                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7617    
7618                    if (!getDB().isSupportsInlineDistinct()) {
7619                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7620                    }
7621    
7622                    if (orderByComparator != null) {
7623                            if (getDB().isSupportsInlineDistinct()) {
7624                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7625                                            orderByComparator, true);
7626                            }
7627                            else {
7628                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7629                                            orderByComparator, true);
7630                            }
7631                    }
7632                    else {
7633                            if (getDB().isSupportsInlineDistinct()) {
7634                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7635                            }
7636                            else {
7637                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7638                            }
7639                    }
7640    
7641                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7642                                    JournalArticle.class.getName(),
7643                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7644    
7645                    Session session = null;
7646    
7647                    try {
7648                            session = openSession();
7649    
7650                            SQLQuery q = session.createSQLQuery(sql);
7651    
7652                            if (getDB().isSupportsInlineDistinct()) {
7653                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7654                            }
7655                            else {
7656                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7657                            }
7658    
7659                            QueryPos qPos = QueryPos.getInstance(q);
7660    
7661                            qPos.add(groupId);
7662    
7663                            qPos.add(userId);
7664    
7665                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7666                                    end);
7667                    }
7668                    catch (Exception e) {
7669                            throw processException(e);
7670                    }
7671                    finally {
7672                            closeSession(session);
7673                    }
7674            }
7675    
7676            /**
7677             * 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;.
7678             *
7679             * @param id the primary key of the current journal article
7680             * @param groupId the group ID
7681             * @param userId the user ID
7682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7683             * @return the previous, current, and next journal article
7684             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7685             * @throws SystemException if a system exception occurred
7686             */
7687            @Override
7688            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
7689                    long userId, OrderByComparator orderByComparator)
7690                    throws NoSuchArticleException, SystemException {
7691                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7692                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
7693                    }
7694    
7695                    JournalArticle journalArticle = findByPrimaryKey(id);
7696    
7697                    Session session = null;
7698    
7699                    try {
7700                            session = openSession();
7701    
7702                            JournalArticle[] array = new JournalArticleImpl[3];
7703    
7704                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
7705                                            groupId, userId, orderByComparator, true);
7706    
7707                            array[1] = journalArticle;
7708    
7709                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
7710                                            groupId, userId, orderByComparator, false);
7711    
7712                            return array;
7713                    }
7714                    catch (Exception e) {
7715                            throw processException(e);
7716                    }
7717                    finally {
7718                            closeSession(session);
7719                    }
7720            }
7721    
7722            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
7723                    JournalArticle journalArticle, long groupId, long userId,
7724                    OrderByComparator orderByComparator, boolean previous) {
7725                    StringBundler query = null;
7726    
7727                    if (orderByComparator != null) {
7728                            query = new StringBundler(6 +
7729                                            (orderByComparator.getOrderByFields().length * 6));
7730                    }
7731                    else {
7732                            query = new StringBundler(3);
7733                    }
7734    
7735                    if (getDB().isSupportsInlineDistinct()) {
7736                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7737                    }
7738                    else {
7739                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7740                    }
7741    
7742                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7743    
7744                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7745    
7746                    if (!getDB().isSupportsInlineDistinct()) {
7747                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7748                    }
7749    
7750                    if (orderByComparator != null) {
7751                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7752    
7753                            if (orderByConditionFields.length > 0) {
7754                                    query.append(WHERE_AND);
7755                            }
7756    
7757                            for (int i = 0; i < orderByConditionFields.length; i++) {
7758                                    if (getDB().isSupportsInlineDistinct()) {
7759                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7760                                    }
7761                                    else {
7762                                            query.append(_ORDER_BY_ENTITY_TABLE);
7763                                    }
7764    
7765                                    query.append(orderByConditionFields[i]);
7766    
7767                                    if ((i + 1) < orderByConditionFields.length) {
7768                                            if (orderByComparator.isAscending() ^ previous) {
7769                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7770                                            }
7771                                            else {
7772                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7773                                            }
7774                                    }
7775                                    else {
7776                                            if (orderByComparator.isAscending() ^ previous) {
7777                                                    query.append(WHERE_GREATER_THAN);
7778                                            }
7779                                            else {
7780                                                    query.append(WHERE_LESSER_THAN);
7781                                            }
7782                                    }
7783                            }
7784    
7785                            query.append(ORDER_BY_CLAUSE);
7786    
7787                            String[] orderByFields = orderByComparator.getOrderByFields();
7788    
7789                            for (int i = 0; i < orderByFields.length; i++) {
7790                                    if (getDB().isSupportsInlineDistinct()) {
7791                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7792                                    }
7793                                    else {
7794                                            query.append(_ORDER_BY_ENTITY_TABLE);
7795                                    }
7796    
7797                                    query.append(orderByFields[i]);
7798    
7799                                    if ((i + 1) < orderByFields.length) {
7800                                            if (orderByComparator.isAscending() ^ previous) {
7801                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7802                                            }
7803                                            else {
7804                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7805                                            }
7806                                    }
7807                                    else {
7808                                            if (orderByComparator.isAscending() ^ previous) {
7809                                                    query.append(ORDER_BY_ASC);
7810                                            }
7811                                            else {
7812                                                    query.append(ORDER_BY_DESC);
7813                                            }
7814                                    }
7815                            }
7816                    }
7817                    else {
7818                            if (getDB().isSupportsInlineDistinct()) {
7819                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7820                            }
7821                            else {
7822                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7823                            }
7824                    }
7825    
7826                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7827                                    JournalArticle.class.getName(),
7828                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7829    
7830                    SQLQuery q = session.createSQLQuery(sql);
7831    
7832                    q.setFirstResult(0);
7833                    q.setMaxResults(2);
7834    
7835                    if (getDB().isSupportsInlineDistinct()) {
7836                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7837                    }
7838                    else {
7839                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7840                    }
7841    
7842                    QueryPos qPos = QueryPos.getInstance(q);
7843    
7844                    qPos.add(groupId);
7845    
7846                    qPos.add(userId);
7847    
7848                    if (orderByComparator != null) {
7849                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7850    
7851                            for (Object value : values) {
7852                                    qPos.add(value);
7853                            }
7854                    }
7855    
7856                    List<JournalArticle> list = q.list();
7857    
7858                    if (list.size() == 2) {
7859                            return list.get(1);
7860                    }
7861                    else {
7862                            return null;
7863                    }
7864            }
7865    
7866            /**
7867             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
7868             *
7869             * @param groupId the group ID
7870             * @param userId the user ID
7871             * @throws SystemException if a system exception occurred
7872             */
7873            @Override
7874            public void removeByG_U(long groupId, long userId)
7875                    throws SystemException {
7876                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
7877                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7878                            remove(journalArticle);
7879                    }
7880            }
7881    
7882            /**
7883             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
7884             *
7885             * @param groupId the group ID
7886             * @param userId the user ID
7887             * @return the number of matching journal articles
7888             * @throws SystemException if a system exception occurred
7889             */
7890            @Override
7891            public int countByG_U(long groupId, long userId) throws SystemException {
7892                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
7893    
7894                    Object[] finderArgs = new Object[] { groupId, userId };
7895    
7896                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7897                                    this);
7898    
7899                    if (count == null) {
7900                            StringBundler query = new StringBundler(3);
7901    
7902                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7903    
7904                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7905    
7906                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7907    
7908                            String sql = query.toString();
7909    
7910                            Session session = null;
7911    
7912                            try {
7913                                    session = openSession();
7914    
7915                                    Query q = session.createQuery(sql);
7916    
7917                                    QueryPos qPos = QueryPos.getInstance(q);
7918    
7919                                    qPos.add(groupId);
7920    
7921                                    qPos.add(userId);
7922    
7923                                    count = (Long)q.uniqueResult();
7924    
7925                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7926                            }
7927                            catch (Exception e) {
7928                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7929    
7930                                    throw processException(e);
7931                            }
7932                            finally {
7933                                    closeSession(session);
7934                            }
7935                    }
7936    
7937                    return count.intValue();
7938            }
7939    
7940            /**
7941             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7942             *
7943             * @param groupId the group ID
7944             * @param userId the user ID
7945             * @return the number of matching journal articles that the user has permission to view
7946             * @throws SystemException if a system exception occurred
7947             */
7948            @Override
7949            public int filterCountByG_U(long groupId, long userId)
7950                    throws SystemException {
7951                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7952                            return countByG_U(groupId, userId);
7953                    }
7954    
7955                    StringBundler query = new StringBundler(3);
7956    
7957                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7958    
7959                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7960    
7961                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7962    
7963                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7964                                    JournalArticle.class.getName(),
7965                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7966    
7967                    Session session = null;
7968    
7969                    try {
7970                            session = openSession();
7971    
7972                            SQLQuery q = session.createSQLQuery(sql);
7973    
7974                            q.addScalar(COUNT_COLUMN_NAME,
7975                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7976    
7977                            QueryPos qPos = QueryPos.getInstance(q);
7978    
7979                            qPos.add(groupId);
7980    
7981                            qPos.add(userId);
7982    
7983                            Long count = (Long)q.uniqueResult();
7984    
7985                            return count.intValue();
7986                    }
7987                    catch (Exception e) {
7988                            throw processException(e);
7989                    }
7990                    finally {
7991                            closeSession(session);
7992                    }
7993            }
7994    
7995            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
7996            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
7997            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7998                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7999                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
8000                            "findByG_F",
8001                            new String[] {
8002                                    Long.class.getName(), Long.class.getName(),
8003                                    
8004                            Integer.class.getName(), Integer.class.getName(),
8005                                    OrderByComparator.class.getName()
8006                            });
8007            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8008                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8009                            JournalArticleImpl.class,
8010                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
8011                            new String[] { Long.class.getName(), Long.class.getName() },
8012                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
8013                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
8014                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
8015                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
8016            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8017                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8018                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
8019                            new String[] { Long.class.getName(), Long.class.getName() });
8020            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8021                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8022                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
8023                            new String[] { Long.class.getName(), Long.class.getName() });
8024    
8025            /**
8026             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
8027             *
8028             * @param groupId the group ID
8029             * @param folderId the folder ID
8030             * @return the matching journal articles
8031             * @throws SystemException if a system exception occurred
8032             */
8033            @Override
8034            public List<JournalArticle> findByG_F(long groupId, long folderId)
8035                    throws SystemException {
8036                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
8037                            QueryUtil.ALL_POS, null);
8038            }
8039    
8040            /**
8041             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
8042             *
8043             * <p>
8044             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8045             * </p>
8046             *
8047             * @param groupId the group ID
8048             * @param folderId the folder ID
8049             * @param start the lower bound of the range of journal articles
8050             * @param end the upper bound of the range of journal articles (not inclusive)
8051             * @return the range of matching journal articles
8052             * @throws SystemException if a system exception occurred
8053             */
8054            @Override
8055            public List<JournalArticle> findByG_F(long groupId, long folderId,
8056                    int start, int end) throws SystemException {
8057                    return findByG_F(groupId, folderId, start, end, null);
8058            }
8059    
8060            /**
8061             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
8062             *
8063             * <p>
8064             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8065             * </p>
8066             *
8067             * @param groupId the group ID
8068             * @param folderId the folder ID
8069             * @param start the lower bound of the range of journal articles
8070             * @param end the upper bound of the range of journal articles (not inclusive)
8071             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8072             * @return the ordered range of matching journal articles
8073             * @throws SystemException if a system exception occurred
8074             */
8075            @Override
8076            public List<JournalArticle> findByG_F(long groupId, long folderId,
8077                    int start, int end, OrderByComparator orderByComparator)
8078                    throws SystemException {
8079                    boolean pagination = true;
8080                    FinderPath finderPath = null;
8081                    Object[] finderArgs = null;
8082    
8083                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8084                                    (orderByComparator == null)) {
8085                            pagination = false;
8086                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
8087                            finderArgs = new Object[] { groupId, folderId };
8088                    }
8089                    else {
8090                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
8091                            finderArgs = new Object[] {
8092                                            groupId, folderId,
8093                                            
8094                                            start, end, orderByComparator
8095                                    };
8096                    }
8097    
8098                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8099                                    finderArgs, this);
8100    
8101                    if ((list != null) && !list.isEmpty()) {
8102                            for (JournalArticle journalArticle : list) {
8103                                    if ((groupId != journalArticle.getGroupId()) ||
8104                                                    (folderId != journalArticle.getFolderId())) {
8105                                            list = null;
8106    
8107                                            break;
8108                                    }
8109                            }
8110                    }
8111    
8112                    if (list == null) {
8113                            StringBundler query = null;
8114    
8115                            if (orderByComparator != null) {
8116                                    query = new StringBundler(4 +
8117                                                    (orderByComparator.getOrderByFields().length * 3));
8118                            }
8119                            else {
8120                                    query = new StringBundler(4);
8121                            }
8122    
8123                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8124    
8125                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8126    
8127                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8128    
8129                            if (orderByComparator != null) {
8130                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8131                                            orderByComparator);
8132                            }
8133                            else
8134                             if (pagination) {
8135                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8136                            }
8137    
8138                            String sql = query.toString();
8139    
8140                            Session session = null;
8141    
8142                            try {
8143                                    session = openSession();
8144    
8145                                    Query q = session.createQuery(sql);
8146    
8147                                    QueryPos qPos = QueryPos.getInstance(q);
8148    
8149                                    qPos.add(groupId);
8150    
8151                                    qPos.add(folderId);
8152    
8153                                    if (!pagination) {
8154                                            list = (List<JournalArticle>)QueryUtil.list(q,
8155                                                            getDialect(), start, end, false);
8156    
8157                                            Collections.sort(list);
8158    
8159                                            list = new UnmodifiableList<JournalArticle>(list);
8160                                    }
8161                                    else {
8162                                            list = (List<JournalArticle>)QueryUtil.list(q,
8163                                                            getDialect(), start, end);
8164                                    }
8165    
8166                                    cacheResult(list);
8167    
8168                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8169                            }
8170                            catch (Exception e) {
8171                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8172    
8173                                    throw processException(e);
8174                            }
8175                            finally {
8176                                    closeSession(session);
8177                            }
8178                    }
8179    
8180                    return list;
8181            }
8182    
8183            /**
8184             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8185             *
8186             * @param groupId the group ID
8187             * @param folderId the folder ID
8188             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8189             * @return the first matching journal article
8190             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8191             * @throws SystemException if a system exception occurred
8192             */
8193            @Override
8194            public JournalArticle findByG_F_First(long groupId, long folderId,
8195                    OrderByComparator orderByComparator)
8196                    throws NoSuchArticleException, SystemException {
8197                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
8198                                    orderByComparator);
8199    
8200                    if (journalArticle != null) {
8201                            return journalArticle;
8202                    }
8203    
8204                    StringBundler msg = new StringBundler(6);
8205    
8206                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8207    
8208                    msg.append("groupId=");
8209                    msg.append(groupId);
8210    
8211                    msg.append(", folderId=");
8212                    msg.append(folderId);
8213    
8214                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8215    
8216                    throw new NoSuchArticleException(msg.toString());
8217            }
8218    
8219            /**
8220             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8221             *
8222             * @param groupId the group ID
8223             * @param folderId the folder ID
8224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8225             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8226             * @throws SystemException if a system exception occurred
8227             */
8228            @Override
8229            public JournalArticle fetchByG_F_First(long groupId, long folderId,
8230                    OrderByComparator orderByComparator) throws SystemException {
8231                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
8232                                    orderByComparator);
8233    
8234                    if (!list.isEmpty()) {
8235                            return list.get(0);
8236                    }
8237    
8238                    return null;
8239            }
8240    
8241            /**
8242             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8243             *
8244             * @param groupId the group ID
8245             * @param folderId the folder ID
8246             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8247             * @return the last matching journal article
8248             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8249             * @throws SystemException if a system exception occurred
8250             */
8251            @Override
8252            public JournalArticle findByG_F_Last(long groupId, long folderId,
8253                    OrderByComparator orderByComparator)
8254                    throws NoSuchArticleException, SystemException {
8255                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
8256                                    orderByComparator);
8257    
8258                    if (journalArticle != null) {
8259                            return journalArticle;
8260                    }
8261    
8262                    StringBundler msg = new StringBundler(6);
8263    
8264                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8265    
8266                    msg.append("groupId=");
8267                    msg.append(groupId);
8268    
8269                    msg.append(", folderId=");
8270                    msg.append(folderId);
8271    
8272                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8273    
8274                    throw new NoSuchArticleException(msg.toString());
8275            }
8276    
8277            /**
8278             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8279             *
8280             * @param groupId the group ID
8281             * @param folderId the folder ID
8282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8283             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8284             * @throws SystemException if a system exception occurred
8285             */
8286            @Override
8287            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
8288                    OrderByComparator orderByComparator) throws SystemException {
8289                    int count = countByG_F(groupId, folderId);
8290    
8291                    if (count == 0) {
8292                            return null;
8293                    }
8294    
8295                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
8296                                    count, orderByComparator);
8297    
8298                    if (!list.isEmpty()) {
8299                            return list.get(0);
8300                    }
8301    
8302                    return null;
8303            }
8304    
8305            /**
8306             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8307             *
8308             * @param id the primary key of the current journal article
8309             * @param groupId the group ID
8310             * @param folderId the folder ID
8311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8312             * @return the previous, current, and next journal article
8313             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8314             * @throws SystemException if a system exception occurred
8315             */
8316            @Override
8317            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
8318                    long folderId, OrderByComparator orderByComparator)
8319                    throws NoSuchArticleException, SystemException {
8320                    JournalArticle journalArticle = findByPrimaryKey(id);
8321    
8322                    Session session = null;
8323    
8324                    try {
8325                            session = openSession();
8326    
8327                            JournalArticle[] array = new JournalArticleImpl[3];
8328    
8329                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8330                                            folderId, orderByComparator, true);
8331    
8332                            array[1] = journalArticle;
8333    
8334                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8335                                            folderId, orderByComparator, false);
8336    
8337                            return array;
8338                    }
8339                    catch (Exception e) {
8340                            throw processException(e);
8341                    }
8342                    finally {
8343                            closeSession(session);
8344                    }
8345            }
8346    
8347            protected JournalArticle getByG_F_PrevAndNext(Session session,
8348                    JournalArticle journalArticle, long groupId, long folderId,
8349                    OrderByComparator orderByComparator, boolean previous) {
8350                    StringBundler query = null;
8351    
8352                    if (orderByComparator != null) {
8353                            query = new StringBundler(6 +
8354                                            (orderByComparator.getOrderByFields().length * 6));
8355                    }
8356                    else {
8357                            query = new StringBundler(3);
8358                    }
8359    
8360                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8361    
8362                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8363    
8364                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8365    
8366                    if (orderByComparator != null) {
8367                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8368    
8369                            if (orderByConditionFields.length > 0) {
8370                                    query.append(WHERE_AND);
8371                            }
8372    
8373                            for (int i = 0; i < orderByConditionFields.length; i++) {
8374                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8375                                    query.append(orderByConditionFields[i]);
8376    
8377                                    if ((i + 1) < orderByConditionFields.length) {
8378                                            if (orderByComparator.isAscending() ^ previous) {
8379                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8380                                            }
8381                                            else {
8382                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8383                                            }
8384                                    }
8385                                    else {
8386                                            if (orderByComparator.isAscending() ^ previous) {
8387                                                    query.append(WHERE_GREATER_THAN);
8388                                            }
8389                                            else {
8390                                                    query.append(WHERE_LESSER_THAN);
8391                                            }
8392                                    }
8393                            }
8394    
8395                            query.append(ORDER_BY_CLAUSE);
8396    
8397                            String[] orderByFields = orderByComparator.getOrderByFields();
8398    
8399                            for (int i = 0; i < orderByFields.length; i++) {
8400                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8401                                    query.append(orderByFields[i]);
8402    
8403                                    if ((i + 1) < orderByFields.length) {
8404                                            if (orderByComparator.isAscending() ^ previous) {
8405                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8406                                            }
8407                                            else {
8408                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8409                                            }
8410                                    }
8411                                    else {
8412                                            if (orderByComparator.isAscending() ^ previous) {
8413                                                    query.append(ORDER_BY_ASC);
8414                                            }
8415                                            else {
8416                                                    query.append(ORDER_BY_DESC);
8417                                            }
8418                                    }
8419                            }
8420                    }
8421                    else {
8422                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8423                    }
8424    
8425                    String sql = query.toString();
8426    
8427                    Query q = session.createQuery(sql);
8428    
8429                    q.setFirstResult(0);
8430                    q.setMaxResults(2);
8431    
8432                    QueryPos qPos = QueryPos.getInstance(q);
8433    
8434                    qPos.add(groupId);
8435    
8436                    qPos.add(folderId);
8437    
8438                    if (orderByComparator != null) {
8439                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8440    
8441                            for (Object value : values) {
8442                                    qPos.add(value);
8443                            }
8444                    }
8445    
8446                    List<JournalArticle> list = q.list();
8447    
8448                    if (list.size() == 2) {
8449                            return list.get(1);
8450                    }
8451                    else {
8452                            return null;
8453                    }
8454            }
8455    
8456            /**
8457             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8458             *
8459             * @param groupId the group ID
8460             * @param folderId the folder ID
8461             * @return the matching journal articles that the user has permission to view
8462             * @throws SystemException if a system exception occurred
8463             */
8464            @Override
8465            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
8466                    throws SystemException {
8467                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
8468                            QueryUtil.ALL_POS, null);
8469            }
8470    
8471            /**
8472             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8473             *
8474             * <p>
8475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8476             * </p>
8477             *
8478             * @param groupId the group ID
8479             * @param folderId the folder ID
8480             * @param start the lower bound of the range of journal articles
8481             * @param end the upper bound of the range of journal articles (not inclusive)
8482             * @return the range of matching journal articles that the user has permission to view
8483             * @throws SystemException if a system exception occurred
8484             */
8485            @Override
8486            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8487                    int start, int end) throws SystemException {
8488                    return filterFindByG_F(groupId, folderId, start, end, null);
8489            }
8490    
8491            /**
8492             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
8493             *
8494             * <p>
8495             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8496             * </p>
8497             *
8498             * @param groupId the group ID
8499             * @param folderId the folder ID
8500             * @param start the lower bound of the range of journal articles
8501             * @param end the upper bound of the range of journal articles (not inclusive)
8502             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8503             * @return the ordered range of matching journal articles that the user has permission to view
8504             * @throws SystemException if a system exception occurred
8505             */
8506            @Override
8507            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8508                    int start, int end, OrderByComparator orderByComparator)
8509                    throws SystemException {
8510                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8511                            return findByG_F(groupId, folderId, start, end, orderByComparator);
8512                    }
8513    
8514                    StringBundler query = null;
8515    
8516                    if (orderByComparator != null) {
8517                            query = new StringBundler(4 +
8518                                            (orderByComparator.getOrderByFields().length * 3));
8519                    }
8520                    else {
8521                            query = new StringBundler(4);
8522                    }
8523    
8524                    if (getDB().isSupportsInlineDistinct()) {
8525                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8526                    }
8527                    else {
8528                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8529                    }
8530    
8531                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8532    
8533                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8534    
8535                    if (!getDB().isSupportsInlineDistinct()) {
8536                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8537                    }
8538    
8539                    if (orderByComparator != null) {
8540                            if (getDB().isSupportsInlineDistinct()) {
8541                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8542                                            orderByComparator, true);
8543                            }
8544                            else {
8545                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8546                                            orderByComparator, true);
8547                            }
8548                    }
8549                    else {
8550                            if (getDB().isSupportsInlineDistinct()) {
8551                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8552                            }
8553                            else {
8554                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8555                            }
8556                    }
8557    
8558                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8559                                    JournalArticle.class.getName(),
8560                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8561    
8562                    Session session = null;
8563    
8564                    try {
8565                            session = openSession();
8566    
8567                            SQLQuery q = session.createSQLQuery(sql);
8568    
8569                            if (getDB().isSupportsInlineDistinct()) {
8570                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8571                            }
8572                            else {
8573                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8574                            }
8575    
8576                            QueryPos qPos = QueryPos.getInstance(q);
8577    
8578                            qPos.add(groupId);
8579    
8580                            qPos.add(folderId);
8581    
8582                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8583                                    end);
8584                    }
8585                    catch (Exception e) {
8586                            throw processException(e);
8587                    }
8588                    finally {
8589                            closeSession(session);
8590                    }
8591            }
8592    
8593            /**
8594             * 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;.
8595             *
8596             * @param id the primary key of the current journal article
8597             * @param groupId the group ID
8598             * @param folderId the folder ID
8599             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8600             * @return the previous, current, and next journal article
8601             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8602             * @throws SystemException if a system exception occurred
8603             */
8604            @Override
8605            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
8606                    long folderId, OrderByComparator orderByComparator)
8607                    throws NoSuchArticleException, SystemException {
8608                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8609                            return findByG_F_PrevAndNext(id, groupId, folderId,
8610                                    orderByComparator);
8611                    }
8612    
8613                    JournalArticle journalArticle = findByPrimaryKey(id);
8614    
8615                    Session session = null;
8616    
8617                    try {
8618                            session = openSession();
8619    
8620                            JournalArticle[] array = new JournalArticleImpl[3];
8621    
8622                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
8623                                            groupId, folderId, orderByComparator, true);
8624    
8625                            array[1] = journalArticle;
8626    
8627                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
8628                                            groupId, folderId, orderByComparator, false);
8629    
8630                            return array;
8631                    }
8632                    catch (Exception e) {
8633                            throw processException(e);
8634                    }
8635                    finally {
8636                            closeSession(session);
8637                    }
8638            }
8639    
8640            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
8641                    JournalArticle journalArticle, long groupId, long folderId,
8642                    OrderByComparator orderByComparator, boolean previous) {
8643                    StringBundler query = null;
8644    
8645                    if (orderByComparator != null) {
8646                            query = new StringBundler(6 +
8647                                            (orderByComparator.getOrderByFields().length * 6));
8648                    }
8649                    else {
8650                            query = new StringBundler(3);
8651                    }
8652    
8653                    if (getDB().isSupportsInlineDistinct()) {
8654                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8655                    }
8656                    else {
8657                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8658                    }
8659    
8660                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8661    
8662                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8663    
8664                    if (!getDB().isSupportsInlineDistinct()) {
8665                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8666                    }
8667    
8668                    if (orderByComparator != null) {
8669                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8670    
8671                            if (orderByConditionFields.length > 0) {
8672                                    query.append(WHERE_AND);
8673                            }
8674    
8675                            for (int i = 0; i < orderByConditionFields.length; i++) {
8676                                    if (getDB().isSupportsInlineDistinct()) {
8677                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8678                                    }
8679                                    else {
8680                                            query.append(_ORDER_BY_ENTITY_TABLE);
8681                                    }
8682    
8683                                    query.append(orderByConditionFields[i]);
8684    
8685                                    if ((i + 1) < orderByConditionFields.length) {
8686                                            if (orderByComparator.isAscending() ^ previous) {
8687                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8688                                            }
8689                                            else {
8690                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8691                                            }
8692                                    }
8693                                    else {
8694                                            if (orderByComparator.isAscending() ^ previous) {
8695                                                    query.append(WHERE_GREATER_THAN);
8696                                            }
8697                                            else {
8698                                                    query.append(WHERE_LESSER_THAN);
8699                                            }
8700                                    }
8701                            }
8702    
8703                            query.append(ORDER_BY_CLAUSE);
8704    
8705                            String[] orderByFields = orderByComparator.getOrderByFields();
8706    
8707                            for (int i = 0; i < orderByFields.length; i++) {
8708                                    if (getDB().isSupportsInlineDistinct()) {
8709                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8710                                    }
8711                                    else {
8712                                            query.append(_ORDER_BY_ENTITY_TABLE);
8713                                    }
8714    
8715                                    query.append(orderByFields[i]);
8716    
8717                                    if ((i + 1) < orderByFields.length) {
8718                                            if (orderByComparator.isAscending() ^ previous) {
8719                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8720                                            }
8721                                            else {
8722                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8723                                            }
8724                                    }
8725                                    else {
8726                                            if (orderByComparator.isAscending() ^ previous) {
8727                                                    query.append(ORDER_BY_ASC);
8728                                            }
8729                                            else {
8730                                                    query.append(ORDER_BY_DESC);
8731                                            }
8732                                    }
8733                            }
8734                    }
8735                    else {
8736                            if (getDB().isSupportsInlineDistinct()) {
8737                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8738                            }
8739                            else {
8740                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8741                            }
8742                    }
8743    
8744                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8745                                    JournalArticle.class.getName(),
8746                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8747    
8748                    SQLQuery q = session.createSQLQuery(sql);
8749    
8750                    q.setFirstResult(0);
8751                    q.setMaxResults(2);
8752    
8753                    if (getDB().isSupportsInlineDistinct()) {
8754                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8755                    }
8756                    else {
8757                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8758                    }
8759    
8760                    QueryPos qPos = QueryPos.getInstance(q);
8761    
8762                    qPos.add(groupId);
8763    
8764                    qPos.add(folderId);
8765    
8766                    if (orderByComparator != null) {
8767                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8768    
8769                            for (Object value : values) {
8770                                    qPos.add(value);
8771                            }
8772                    }
8773    
8774                    List<JournalArticle> list = q.list();
8775    
8776                    if (list.size() == 2) {
8777                            return list.get(1);
8778                    }
8779                    else {
8780                            return null;
8781                    }
8782            }
8783    
8784            /**
8785             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8786             *
8787             * @param groupId the group ID
8788             * @param folderIds the folder IDs
8789             * @return the matching journal articles that the user has permission to view
8790             * @throws SystemException if a system exception occurred
8791             */
8792            @Override
8793            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
8794                    throws SystemException {
8795                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8796                            QueryUtil.ALL_POS, null);
8797            }
8798    
8799            /**
8800             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8801             *
8802             * <p>
8803             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8804             * </p>
8805             *
8806             * @param groupId the group ID
8807             * @param folderIds the folder IDs
8808             * @param start the lower bound of the range of journal articles
8809             * @param end the upper bound of the range of journal articles (not inclusive)
8810             * @return the range of matching journal articles that the user has permission to view
8811             * @throws SystemException if a system exception occurred
8812             */
8813            @Override
8814            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8815                    int start, int end) throws SystemException {
8816                    return filterFindByG_F(groupId, folderIds, start, end, null);
8817            }
8818    
8819            /**
8820             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8821             *
8822             * <p>
8823             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8824             * </p>
8825             *
8826             * @param groupId the group ID
8827             * @param folderIds the folder IDs
8828             * @param start the lower bound of the range of journal articles
8829             * @param end the upper bound of the range of journal articles (not inclusive)
8830             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8831             * @return the ordered range of matching journal articles that the user has permission to view
8832             * @throws SystemException if a system exception occurred
8833             */
8834            @Override
8835            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8836                    int start, int end, OrderByComparator orderByComparator)
8837                    throws SystemException {
8838                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8839                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8840                    }
8841    
8842                    StringBundler query = new StringBundler();
8843    
8844                    if (getDB().isSupportsInlineDistinct()) {
8845                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8846                    }
8847                    else {
8848                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8849                    }
8850    
8851                    boolean conjunctionable = false;
8852    
8853                    if (conjunctionable) {
8854                            query.append(WHERE_AND);
8855                    }
8856    
8857                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8858    
8859                    conjunctionable = true;
8860    
8861                    if ((folderIds == null) || (folderIds.length > 0)) {
8862                            if (conjunctionable) {
8863                                    query.append(WHERE_AND);
8864                            }
8865    
8866                            query.append(StringPool.OPEN_PARENTHESIS);
8867    
8868                            for (int i = 0; i < folderIds.length; i++) {
8869                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8870    
8871                                    if ((i + 1) < folderIds.length) {
8872                                            query.append(WHERE_OR);
8873                                    }
8874                            }
8875    
8876                            query.append(StringPool.CLOSE_PARENTHESIS);
8877    
8878                            conjunctionable = true;
8879                    }
8880    
8881                    if (!getDB().isSupportsInlineDistinct()) {
8882                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8883                    }
8884    
8885                    if (orderByComparator != null) {
8886                            if (getDB().isSupportsInlineDistinct()) {
8887                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8888                                            orderByComparator, true);
8889                            }
8890                            else {
8891                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8892                                            orderByComparator, true);
8893                            }
8894                    }
8895                    else {
8896                            if (getDB().isSupportsInlineDistinct()) {
8897                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8898                            }
8899                            else {
8900                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8901                            }
8902                    }
8903    
8904                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8905                                    JournalArticle.class.getName(),
8906                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8907    
8908                    Session session = null;
8909    
8910                    try {
8911                            session = openSession();
8912    
8913                            SQLQuery q = session.createSQLQuery(sql);
8914    
8915                            if (getDB().isSupportsInlineDistinct()) {
8916                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8917                            }
8918                            else {
8919                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8920                            }
8921    
8922                            QueryPos qPos = QueryPos.getInstance(q);
8923    
8924                            qPos.add(groupId);
8925    
8926                            if (folderIds != null) {
8927                                    qPos.add(folderIds);
8928                            }
8929    
8930                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8931                                    end);
8932                    }
8933                    catch (Exception e) {
8934                            throw processException(e);
8935                    }
8936                    finally {
8937                            closeSession(session);
8938                    }
8939            }
8940    
8941            /**
8942             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
8943             *
8944             * <p>
8945             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8946             * </p>
8947             *
8948             * @param groupId the group ID
8949             * @param folderIds the folder IDs
8950             * @return the matching journal articles
8951             * @throws SystemException if a system exception occurred
8952             */
8953            @Override
8954            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
8955                    throws SystemException {
8956                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8957                            QueryUtil.ALL_POS, null);
8958            }
8959    
8960            /**
8961             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8962             *
8963             * <p>
8964             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8965             * </p>
8966             *
8967             * @param groupId the group ID
8968             * @param folderIds the folder IDs
8969             * @param start the lower bound of the range of journal articles
8970             * @param end the upper bound of the range of journal articles (not inclusive)
8971             * @return the range of matching journal articles
8972             * @throws SystemException if a system exception occurred
8973             */
8974            @Override
8975            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8976                    int start, int end) throws SystemException {
8977                    return findByG_F(groupId, folderIds, start, end, null);
8978            }
8979    
8980            /**
8981             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8982             *
8983             * <p>
8984             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8985             * </p>
8986             *
8987             * @param groupId the group ID
8988             * @param folderIds the folder IDs
8989             * @param start the lower bound of the range of journal articles
8990             * @param end the upper bound of the range of journal articles (not inclusive)
8991             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8992             * @return the ordered range of matching journal articles
8993             * @throws SystemException if a system exception occurred
8994             */
8995            @Override
8996            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8997                    int start, int end, OrderByComparator orderByComparator)
8998                    throws SystemException {
8999                    if ((folderIds != null) && (folderIds.length == 1)) {
9000                            return findByG_F(groupId, folderIds[0], start, end,
9001                                    orderByComparator);
9002                    }
9003    
9004                    boolean pagination = true;
9005                    Object[] finderArgs = null;
9006    
9007                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9008                                    (orderByComparator == null)) {
9009                            pagination = false;
9010                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
9011                    }
9012                    else {
9013                            finderArgs = new Object[] {
9014                                            groupId, StringUtil.merge(folderIds),
9015                                            
9016                                            start, end, orderByComparator
9017                                    };
9018                    }
9019    
9020                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9021                                    finderArgs, this);
9022    
9023                    if ((list != null) && !list.isEmpty()) {
9024                            for (JournalArticle journalArticle : list) {
9025                                    if ((groupId != journalArticle.getGroupId()) ||
9026                                                    !ArrayUtil.contains(folderIds,
9027                                                            journalArticle.getFolderId())) {
9028                                            list = null;
9029    
9030                                            break;
9031                                    }
9032                            }
9033                    }
9034    
9035                    if (list == null) {
9036                            StringBundler query = new StringBundler();
9037    
9038                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9039    
9040                            boolean conjunctionable = false;
9041    
9042                            if (conjunctionable) {
9043                                    query.append(WHERE_AND);
9044                            }
9045    
9046                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9047    
9048                            conjunctionable = true;
9049    
9050                            if ((folderIds == null) || (folderIds.length > 0)) {
9051                                    if (conjunctionable) {
9052                                            query.append(WHERE_AND);
9053                                    }
9054    
9055                                    query.append(StringPool.OPEN_PARENTHESIS);
9056    
9057                                    for (int i = 0; i < folderIds.length; i++) {
9058                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9059    
9060                                            if ((i + 1) < folderIds.length) {
9061                                                    query.append(WHERE_OR);
9062                                            }
9063                                    }
9064    
9065                                    query.append(StringPool.CLOSE_PARENTHESIS);
9066    
9067                                    conjunctionable = true;
9068                            }
9069    
9070                            if (orderByComparator != null) {
9071                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9072                                            orderByComparator);
9073                            }
9074                            else
9075                             if (pagination) {
9076                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9077                            }
9078    
9079                            String sql = query.toString();
9080    
9081                            Session session = null;
9082    
9083                            try {
9084                                    session = openSession();
9085    
9086                                    Query q = session.createQuery(sql);
9087    
9088                                    QueryPos qPos = QueryPos.getInstance(q);
9089    
9090                                    qPos.add(groupId);
9091    
9092                                    if (folderIds != null) {
9093                                            qPos.add(folderIds);
9094                                    }
9095    
9096                                    if (!pagination) {
9097                                            list = (List<JournalArticle>)QueryUtil.list(q,
9098                                                            getDialect(), start, end, false);
9099    
9100                                            Collections.sort(list);
9101    
9102                                            list = new UnmodifiableList<JournalArticle>(list);
9103                                    }
9104                                    else {
9105                                            list = (List<JournalArticle>)QueryUtil.list(q,
9106                                                            getDialect(), start, end);
9107                                    }
9108    
9109                                    cacheResult(list);
9110    
9111                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9112                                            finderArgs, list);
9113                            }
9114                            catch (Exception e) {
9115                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9116                                            finderArgs);
9117    
9118                                    throw processException(e);
9119                            }
9120                            finally {
9121                                    closeSession(session);
9122                            }
9123                    }
9124    
9125                    return list;
9126            }
9127    
9128            /**
9129             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
9130             *
9131             * @param groupId the group ID
9132             * @param folderId the folder ID
9133             * @throws SystemException if a system exception occurred
9134             */
9135            @Override
9136            public void removeByG_F(long groupId, long folderId)
9137                    throws SystemException {
9138                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
9139                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9140                            remove(journalArticle);
9141                    }
9142            }
9143    
9144            /**
9145             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
9146             *
9147             * @param groupId the group ID
9148             * @param folderId the folder ID
9149             * @return the number of matching journal articles
9150             * @throws SystemException if a system exception occurred
9151             */
9152            @Override
9153            public int countByG_F(long groupId, long folderId)
9154                    throws SystemException {
9155                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
9156    
9157                    Object[] finderArgs = new Object[] { groupId, folderId };
9158    
9159                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9160                                    this);
9161    
9162                    if (count == null) {
9163                            StringBundler query = new StringBundler(3);
9164    
9165                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9166    
9167                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9168    
9169                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9170    
9171                            String sql = query.toString();
9172    
9173                            Session session = null;
9174    
9175                            try {
9176                                    session = openSession();
9177    
9178                                    Query q = session.createQuery(sql);
9179    
9180                                    QueryPos qPos = QueryPos.getInstance(q);
9181    
9182                                    qPos.add(groupId);
9183    
9184                                    qPos.add(folderId);
9185    
9186                                    count = (Long)q.uniqueResult();
9187    
9188                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9189                            }
9190                            catch (Exception e) {
9191                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9192    
9193                                    throw processException(e);
9194                            }
9195                            finally {
9196                                    closeSession(session);
9197                            }
9198                    }
9199    
9200                    return count.intValue();
9201            }
9202    
9203            /**
9204             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
9205             *
9206             * @param groupId the group ID
9207             * @param folderIds the folder IDs
9208             * @return the number of matching journal articles
9209             * @throws SystemException if a system exception occurred
9210             */
9211            @Override
9212            public int countByG_F(long groupId, long[] folderIds)
9213                    throws SystemException {
9214                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
9215    
9216                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9217                                    finderArgs, this);
9218    
9219                    if (count == null) {
9220                            StringBundler query = new StringBundler();
9221    
9222                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9223    
9224                            boolean conjunctionable = false;
9225    
9226                            if (conjunctionable) {
9227                                    query.append(WHERE_AND);
9228                            }
9229    
9230                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9231    
9232                            conjunctionable = true;
9233    
9234                            if ((folderIds == null) || (folderIds.length > 0)) {
9235                                    if (conjunctionable) {
9236                                            query.append(WHERE_AND);
9237                                    }
9238    
9239                                    query.append(StringPool.OPEN_PARENTHESIS);
9240    
9241                                    for (int i = 0; i < folderIds.length; i++) {
9242                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9243    
9244                                            if ((i + 1) < folderIds.length) {
9245                                                    query.append(WHERE_OR);
9246                                            }
9247                                    }
9248    
9249                                    query.append(StringPool.CLOSE_PARENTHESIS);
9250    
9251                                    conjunctionable = true;
9252                            }
9253    
9254                            String sql = query.toString();
9255    
9256                            Session session = null;
9257    
9258                            try {
9259                                    session = openSession();
9260    
9261                                    Query q = session.createQuery(sql);
9262    
9263                                    QueryPos qPos = QueryPos.getInstance(q);
9264    
9265                                    qPos.add(groupId);
9266    
9267                                    if (folderIds != null) {
9268                                            qPos.add(folderIds);
9269                                    }
9270    
9271                                    count = (Long)q.uniqueResult();
9272    
9273                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9274                                            finderArgs, count);
9275                            }
9276                            catch (Exception e) {
9277                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9278                                            finderArgs);
9279    
9280                                    throw processException(e);
9281                            }
9282                            finally {
9283                                    closeSession(session);
9284                            }
9285                    }
9286    
9287                    return count.intValue();
9288            }
9289    
9290            /**
9291             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
9292             *
9293             * @param groupId the group ID
9294             * @param folderId the folder ID
9295             * @return the number of matching journal articles that the user has permission to view
9296             * @throws SystemException if a system exception occurred
9297             */
9298            @Override
9299            public int filterCountByG_F(long groupId, long folderId)
9300                    throws SystemException {
9301                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9302                            return countByG_F(groupId, folderId);
9303                    }
9304    
9305                    StringBundler query = new StringBundler(3);
9306    
9307                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9308    
9309                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9310    
9311                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9312    
9313                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9314                                    JournalArticle.class.getName(),
9315                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9316    
9317                    Session session = null;
9318    
9319                    try {
9320                            session = openSession();
9321    
9322                            SQLQuery q = session.createSQLQuery(sql);
9323    
9324                            q.addScalar(COUNT_COLUMN_NAME,
9325                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9326    
9327                            QueryPos qPos = QueryPos.getInstance(q);
9328    
9329                            qPos.add(groupId);
9330    
9331                            qPos.add(folderId);
9332    
9333                            Long count = (Long)q.uniqueResult();
9334    
9335                            return count.intValue();
9336                    }
9337                    catch (Exception e) {
9338                            throw processException(e);
9339                    }
9340                    finally {
9341                            closeSession(session);
9342                    }
9343            }
9344    
9345            /**
9346             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
9347             *
9348             * @param groupId the group ID
9349             * @param folderIds the folder IDs
9350             * @return the number of matching journal articles that the user has permission to view
9351             * @throws SystemException if a system exception occurred
9352             */
9353            @Override
9354            public int filterCountByG_F(long groupId, long[] folderIds)
9355                    throws SystemException {
9356                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9357                            return countByG_F(groupId, folderIds);
9358                    }
9359    
9360                    StringBundler query = new StringBundler();
9361    
9362                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9363    
9364                    boolean conjunctionable = false;
9365    
9366                    if (conjunctionable) {
9367                            query.append(WHERE_AND);
9368                    }
9369    
9370                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9371    
9372                    conjunctionable = true;
9373    
9374                    if ((folderIds == null) || (folderIds.length > 0)) {
9375                            if (conjunctionable) {
9376                                    query.append(WHERE_AND);
9377                            }
9378    
9379                            query.append(StringPool.OPEN_PARENTHESIS);
9380    
9381                            for (int i = 0; i < folderIds.length; i++) {
9382                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9383    
9384                                    if ((i + 1) < folderIds.length) {
9385                                            query.append(WHERE_OR);
9386                                    }
9387                            }
9388    
9389                            query.append(StringPool.CLOSE_PARENTHESIS);
9390    
9391                            conjunctionable = true;
9392                    }
9393    
9394                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9395                                    JournalArticle.class.getName(),
9396                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9397    
9398                    Session session = null;
9399    
9400                    try {
9401                            session = openSession();
9402    
9403                            SQLQuery q = session.createSQLQuery(sql);
9404    
9405                            q.addScalar(COUNT_COLUMN_NAME,
9406                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9407    
9408                            QueryPos qPos = QueryPos.getInstance(q);
9409    
9410                            qPos.add(groupId);
9411    
9412                            if (folderIds != null) {
9413                                    qPos.add(folderIds);
9414                            }
9415    
9416                            Long count = (Long)q.uniqueResult();
9417    
9418                            return count.intValue();
9419                    }
9420                    catch (Exception e) {
9421                            throw processException(e);
9422                    }
9423                    finally {
9424                            closeSession(session);
9425                    }
9426            }
9427    
9428            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
9429            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
9430                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
9431            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
9432            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
9433                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
9434            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9435                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9436                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9437                            "findByG_A",
9438                            new String[] {
9439                                    Long.class.getName(), String.class.getName(),
9440                                    
9441                            Integer.class.getName(), Integer.class.getName(),
9442                                    OrderByComparator.class.getName()
9443                            });
9444            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9445                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9446                            JournalArticleImpl.class,
9447                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
9448                            new String[] { Long.class.getName(), String.class.getName() },
9449                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9450                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9451                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9452            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9453                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9454                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
9455                            new String[] { Long.class.getName(), String.class.getName() });
9456    
9457            /**
9458             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
9459             *
9460             * @param groupId the group ID
9461             * @param articleId the article ID
9462             * @return the matching journal articles
9463             * @throws SystemException if a system exception occurred
9464             */
9465            @Override
9466            public List<JournalArticle> findByG_A(long groupId, String articleId)
9467                    throws SystemException {
9468                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
9469                            QueryUtil.ALL_POS, null);
9470            }
9471    
9472            /**
9473             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
9474             *
9475             * <p>
9476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9477             * </p>
9478             *
9479             * @param groupId the group ID
9480             * @param articleId the article ID
9481             * @param start the lower bound of the range of journal articles
9482             * @param end the upper bound of the range of journal articles (not inclusive)
9483             * @return the range of matching journal articles
9484             * @throws SystemException if a system exception occurred
9485             */
9486            @Override
9487            public List<JournalArticle> findByG_A(long groupId, String articleId,
9488                    int start, int end) throws SystemException {
9489                    return findByG_A(groupId, articleId, start, end, null);
9490            }
9491    
9492            /**
9493             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
9494             *
9495             * <p>
9496             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9497             * </p>
9498             *
9499             * @param groupId the group ID
9500             * @param articleId the article ID
9501             * @param start the lower bound of the range of journal articles
9502             * @param end the upper bound of the range of journal articles (not inclusive)
9503             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9504             * @return the ordered range of matching journal articles
9505             * @throws SystemException if a system exception occurred
9506             */
9507            @Override
9508            public List<JournalArticle> findByG_A(long groupId, String articleId,
9509                    int start, int end, OrderByComparator orderByComparator)
9510                    throws SystemException {
9511                    boolean pagination = true;
9512                    FinderPath finderPath = null;
9513                    Object[] finderArgs = null;
9514    
9515                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9516                                    (orderByComparator == null)) {
9517                            pagination = false;
9518                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
9519                            finderArgs = new Object[] { groupId, articleId };
9520                    }
9521                    else {
9522                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
9523                            finderArgs = new Object[] {
9524                                            groupId, articleId,
9525                                            
9526                                            start, end, orderByComparator
9527                                    };
9528                    }
9529    
9530                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9531                                    finderArgs, this);
9532    
9533                    if ((list != null) && !list.isEmpty()) {
9534                            for (JournalArticle journalArticle : list) {
9535                                    if ((groupId != journalArticle.getGroupId()) ||
9536                                                    !Validator.equals(articleId,
9537                                                            journalArticle.getArticleId())) {
9538                                            list = null;
9539    
9540                                            break;
9541                                    }
9542                            }
9543                    }
9544    
9545                    if (list == null) {
9546                            StringBundler query = null;
9547    
9548                            if (orderByComparator != null) {
9549                                    query = new StringBundler(4 +
9550                                                    (orderByComparator.getOrderByFields().length * 3));
9551                            }
9552                            else {
9553                                    query = new StringBundler(4);
9554                            }
9555    
9556                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9557    
9558                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9559    
9560                            boolean bindArticleId = false;
9561    
9562                            if (articleId == null) {
9563                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9564                            }
9565                            else if (articleId.equals(StringPool.BLANK)) {
9566                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9567                            }
9568                            else {
9569                                    bindArticleId = true;
9570    
9571                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9572                            }
9573    
9574                            if (orderByComparator != null) {
9575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9576                                            orderByComparator);
9577                            }
9578                            else
9579                             if (pagination) {
9580                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9581                            }
9582    
9583                            String sql = query.toString();
9584    
9585                            Session session = null;
9586    
9587                            try {
9588                                    session = openSession();
9589    
9590                                    Query q = session.createQuery(sql);
9591    
9592                                    QueryPos qPos = QueryPos.getInstance(q);
9593    
9594                                    qPos.add(groupId);
9595    
9596                                    if (bindArticleId) {
9597                                            qPos.add(articleId);
9598                                    }
9599    
9600                                    if (!pagination) {
9601                                            list = (List<JournalArticle>)QueryUtil.list(q,
9602                                                            getDialect(), start, end, false);
9603    
9604                                            Collections.sort(list);
9605    
9606                                            list = new UnmodifiableList<JournalArticle>(list);
9607                                    }
9608                                    else {
9609                                            list = (List<JournalArticle>)QueryUtil.list(q,
9610                                                            getDialect(), start, end);
9611                                    }
9612    
9613                                    cacheResult(list);
9614    
9615                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9616                            }
9617                            catch (Exception e) {
9618                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9619    
9620                                    throw processException(e);
9621                            }
9622                            finally {
9623                                    closeSession(session);
9624                            }
9625                    }
9626    
9627                    return list;
9628            }
9629    
9630            /**
9631             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9632             *
9633             * @param groupId the group ID
9634             * @param articleId the article ID
9635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9636             * @return the first matching journal article
9637             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9638             * @throws SystemException if a system exception occurred
9639             */
9640            @Override
9641            public JournalArticle findByG_A_First(long groupId, String articleId,
9642                    OrderByComparator orderByComparator)
9643                    throws NoSuchArticleException, SystemException {
9644                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
9645                                    orderByComparator);
9646    
9647                    if (journalArticle != null) {
9648                            return journalArticle;
9649                    }
9650    
9651                    StringBundler msg = new StringBundler(6);
9652    
9653                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9654    
9655                    msg.append("groupId=");
9656                    msg.append(groupId);
9657    
9658                    msg.append(", articleId=");
9659                    msg.append(articleId);
9660    
9661                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9662    
9663                    throw new NoSuchArticleException(msg.toString());
9664            }
9665    
9666            /**
9667             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9668             *
9669             * @param groupId the group ID
9670             * @param articleId the article ID
9671             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9672             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9673             * @throws SystemException if a system exception occurred
9674             */
9675            @Override
9676            public JournalArticle fetchByG_A_First(long groupId, String articleId,
9677                    OrderByComparator orderByComparator) throws SystemException {
9678                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
9679                                    orderByComparator);
9680    
9681                    if (!list.isEmpty()) {
9682                            return list.get(0);
9683                    }
9684    
9685                    return null;
9686            }
9687    
9688            /**
9689             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9690             *
9691             * @param groupId the group ID
9692             * @param articleId the article ID
9693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9694             * @return the last matching journal article
9695             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9696             * @throws SystemException if a system exception occurred
9697             */
9698            @Override
9699            public JournalArticle findByG_A_Last(long groupId, String articleId,
9700                    OrderByComparator orderByComparator)
9701                    throws NoSuchArticleException, SystemException {
9702                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
9703                                    orderByComparator);
9704    
9705                    if (journalArticle != null) {
9706                            return journalArticle;
9707                    }
9708    
9709                    StringBundler msg = new StringBundler(6);
9710    
9711                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9712    
9713                    msg.append("groupId=");
9714                    msg.append(groupId);
9715    
9716                    msg.append(", articleId=");
9717                    msg.append(articleId);
9718    
9719                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9720    
9721                    throw new NoSuchArticleException(msg.toString());
9722            }
9723    
9724            /**
9725             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9726             *
9727             * @param groupId the group ID
9728             * @param articleId the article ID
9729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9730             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9731             * @throws SystemException if a system exception occurred
9732             */
9733            @Override
9734            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
9735                    OrderByComparator orderByComparator) throws SystemException {
9736                    int count = countByG_A(groupId, articleId);
9737    
9738                    if (count == 0) {
9739                            return null;
9740                    }
9741    
9742                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
9743                                    count, orderByComparator);
9744    
9745                    if (!list.isEmpty()) {
9746                            return list.get(0);
9747                    }
9748    
9749                    return null;
9750            }
9751    
9752            /**
9753             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9754             *
9755             * @param id the primary key of the current journal article
9756             * @param groupId the group ID
9757             * @param articleId the article ID
9758             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9759             * @return the previous, current, and next journal article
9760             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9761             * @throws SystemException if a system exception occurred
9762             */
9763            @Override
9764            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
9765                    String articleId, OrderByComparator orderByComparator)
9766                    throws NoSuchArticleException, SystemException {
9767                    JournalArticle journalArticle = findByPrimaryKey(id);
9768    
9769                    Session session = null;
9770    
9771                    try {
9772                            session = openSession();
9773    
9774                            JournalArticle[] array = new JournalArticleImpl[3];
9775    
9776                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9777                                            articleId, orderByComparator, true);
9778    
9779                            array[1] = journalArticle;
9780    
9781                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9782                                            articleId, orderByComparator, false);
9783    
9784                            return array;
9785                    }
9786                    catch (Exception e) {
9787                            throw processException(e);
9788                    }
9789                    finally {
9790                            closeSession(session);
9791                    }
9792            }
9793    
9794            protected JournalArticle getByG_A_PrevAndNext(Session session,
9795                    JournalArticle journalArticle, long groupId, String articleId,
9796                    OrderByComparator orderByComparator, boolean previous) {
9797                    StringBundler query = null;
9798    
9799                    if (orderByComparator != null) {
9800                            query = new StringBundler(6 +
9801                                            (orderByComparator.getOrderByFields().length * 6));
9802                    }
9803                    else {
9804                            query = new StringBundler(3);
9805                    }
9806    
9807                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9808    
9809                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9810    
9811                    boolean bindArticleId = false;
9812    
9813                    if (articleId == null) {
9814                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9815                    }
9816                    else if (articleId.equals(StringPool.BLANK)) {
9817                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9818                    }
9819                    else {
9820                            bindArticleId = true;
9821    
9822                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9823                    }
9824    
9825                    if (orderByComparator != null) {
9826                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9827    
9828                            if (orderByConditionFields.length > 0) {
9829                                    query.append(WHERE_AND);
9830                            }
9831    
9832                            for (int i = 0; i < orderByConditionFields.length; i++) {
9833                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9834                                    query.append(orderByConditionFields[i]);
9835    
9836                                    if ((i + 1) < orderByConditionFields.length) {
9837                                            if (orderByComparator.isAscending() ^ previous) {
9838                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9839                                            }
9840                                            else {
9841                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9842                                            }
9843                                    }
9844                                    else {
9845                                            if (orderByComparator.isAscending() ^ previous) {
9846                                                    query.append(WHERE_GREATER_THAN);
9847                                            }
9848                                            else {
9849                                                    query.append(WHERE_LESSER_THAN);
9850                                            }
9851                                    }
9852                            }
9853    
9854                            query.append(ORDER_BY_CLAUSE);
9855    
9856                            String[] orderByFields = orderByComparator.getOrderByFields();
9857    
9858                            for (int i = 0; i < orderByFields.length; i++) {
9859                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9860                                    query.append(orderByFields[i]);
9861    
9862                                    if ((i + 1) < orderByFields.length) {
9863                                            if (orderByComparator.isAscending() ^ previous) {
9864                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9865                                            }
9866                                            else {
9867                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9868                                            }
9869                                    }
9870                                    else {
9871                                            if (orderByComparator.isAscending() ^ previous) {
9872                                                    query.append(ORDER_BY_ASC);
9873                                            }
9874                                            else {
9875                                                    query.append(ORDER_BY_DESC);
9876                                            }
9877                                    }
9878                            }
9879                    }
9880                    else {
9881                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9882                    }
9883    
9884                    String sql = query.toString();
9885    
9886                    Query q = session.createQuery(sql);
9887    
9888                    q.setFirstResult(0);
9889                    q.setMaxResults(2);
9890    
9891                    QueryPos qPos = QueryPos.getInstance(q);
9892    
9893                    qPos.add(groupId);
9894    
9895                    if (bindArticleId) {
9896                            qPos.add(articleId);
9897                    }
9898    
9899                    if (orderByComparator != null) {
9900                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9901    
9902                            for (Object value : values) {
9903                                    qPos.add(value);
9904                            }
9905                    }
9906    
9907                    List<JournalArticle> list = q.list();
9908    
9909                    if (list.size() == 2) {
9910                            return list.get(1);
9911                    }
9912                    else {
9913                            return null;
9914                    }
9915            }
9916    
9917            /**
9918             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9919             *
9920             * @param groupId the group ID
9921             * @param articleId the article ID
9922             * @return the matching journal articles that the user has permission to view
9923             * @throws SystemException if a system exception occurred
9924             */
9925            @Override
9926            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
9927                    throws SystemException {
9928                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
9929                            QueryUtil.ALL_POS, null);
9930            }
9931    
9932            /**
9933             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9934             *
9935             * <p>
9936             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9937             * </p>
9938             *
9939             * @param groupId the group ID
9940             * @param articleId the article ID
9941             * @param start the lower bound of the range of journal articles
9942             * @param end the upper bound of the range of journal articles (not inclusive)
9943             * @return the range of matching journal articles that the user has permission to view
9944             * @throws SystemException if a system exception occurred
9945             */
9946            @Override
9947            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9948                    int start, int end) throws SystemException {
9949                    return filterFindByG_A(groupId, articleId, start, end, null);
9950            }
9951    
9952            /**
9953             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
9954             *
9955             * <p>
9956             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9957             * </p>
9958             *
9959             * @param groupId the group ID
9960             * @param articleId the article ID
9961             * @param start the lower bound of the range of journal articles
9962             * @param end the upper bound of the range of journal articles (not inclusive)
9963             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9964             * @return the ordered range of matching journal articles that the user has permission to view
9965             * @throws SystemException if a system exception occurred
9966             */
9967            @Override
9968            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9969                    int start, int end, OrderByComparator orderByComparator)
9970                    throws SystemException {
9971                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9972                            return findByG_A(groupId, articleId, start, end, orderByComparator);
9973                    }
9974    
9975                    StringBundler query = null;
9976    
9977                    if (orderByComparator != null) {
9978                            query = new StringBundler(4 +
9979                                            (orderByComparator.getOrderByFields().length * 3));
9980                    }
9981                    else {
9982                            query = new StringBundler(4);
9983                    }
9984    
9985                    if (getDB().isSupportsInlineDistinct()) {
9986                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9987                    }
9988                    else {
9989                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9990                    }
9991    
9992                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9993    
9994                    boolean bindArticleId = false;
9995    
9996                    if (articleId == null) {
9997                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9998                    }
9999                    else if (articleId.equals(StringPool.BLANK)) {
10000                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10001                    }
10002                    else {
10003                            bindArticleId = true;
10004    
10005                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10006                    }
10007    
10008                    if (!getDB().isSupportsInlineDistinct()) {
10009                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10010                    }
10011    
10012                    if (orderByComparator != null) {
10013                            if (getDB().isSupportsInlineDistinct()) {
10014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10015                                            orderByComparator, true);
10016                            }
10017                            else {
10018                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10019                                            orderByComparator, true);
10020                            }
10021                    }
10022                    else {
10023                            if (getDB().isSupportsInlineDistinct()) {
10024                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10025                            }
10026                            else {
10027                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10028                            }
10029                    }
10030    
10031                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10032                                    JournalArticle.class.getName(),
10033                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10034    
10035                    Session session = null;
10036    
10037                    try {
10038                            session = openSession();
10039    
10040                            SQLQuery q = session.createSQLQuery(sql);
10041    
10042                            if (getDB().isSupportsInlineDistinct()) {
10043                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10044                            }
10045                            else {
10046                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10047                            }
10048    
10049                            QueryPos qPos = QueryPos.getInstance(q);
10050    
10051                            qPos.add(groupId);
10052    
10053                            if (bindArticleId) {
10054                                    qPos.add(articleId);
10055                            }
10056    
10057                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10058                                    end);
10059                    }
10060                    catch (Exception e) {
10061                            throw processException(e);
10062                    }
10063                    finally {
10064                            closeSession(session);
10065                    }
10066            }
10067    
10068            /**
10069             * 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;.
10070             *
10071             * @param id the primary key of the current journal article
10072             * @param groupId the group ID
10073             * @param articleId the article ID
10074             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10075             * @return the previous, current, and next journal article
10076             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10077             * @throws SystemException if a system exception occurred
10078             */
10079            @Override
10080            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
10081                    String articleId, OrderByComparator orderByComparator)
10082                    throws NoSuchArticleException, SystemException {
10083                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10084                            return findByG_A_PrevAndNext(id, groupId, articleId,
10085                                    orderByComparator);
10086                    }
10087    
10088                    JournalArticle journalArticle = findByPrimaryKey(id);
10089    
10090                    Session session = null;
10091    
10092                    try {
10093                            session = openSession();
10094    
10095                            JournalArticle[] array = new JournalArticleImpl[3];
10096    
10097                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
10098                                            groupId, articleId, orderByComparator, true);
10099    
10100                            array[1] = journalArticle;
10101    
10102                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
10103                                            groupId, articleId, orderByComparator, false);
10104    
10105                            return array;
10106                    }
10107                    catch (Exception e) {
10108                            throw processException(e);
10109                    }
10110                    finally {
10111                            closeSession(session);
10112                    }
10113            }
10114    
10115            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
10116                    JournalArticle journalArticle, long groupId, String articleId,
10117                    OrderByComparator orderByComparator, boolean previous) {
10118                    StringBundler query = null;
10119    
10120                    if (orderByComparator != null) {
10121                            query = new StringBundler(6 +
10122                                            (orderByComparator.getOrderByFields().length * 6));
10123                    }
10124                    else {
10125                            query = new StringBundler(3);
10126                    }
10127    
10128                    if (getDB().isSupportsInlineDistinct()) {
10129                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10130                    }
10131                    else {
10132                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10133                    }
10134    
10135                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10136    
10137                    boolean bindArticleId = false;
10138    
10139                    if (articleId == null) {
10140                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10141                    }
10142                    else if (articleId.equals(StringPool.BLANK)) {
10143                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10144                    }
10145                    else {
10146                            bindArticleId = true;
10147    
10148                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10149                    }
10150    
10151                    if (!getDB().isSupportsInlineDistinct()) {
10152                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10153                    }
10154    
10155                    if (orderByComparator != null) {
10156                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10157    
10158                            if (orderByConditionFields.length > 0) {
10159                                    query.append(WHERE_AND);
10160                            }
10161    
10162                            for (int i = 0; i < orderByConditionFields.length; i++) {
10163                                    if (getDB().isSupportsInlineDistinct()) {
10164                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10165                                    }
10166                                    else {
10167                                            query.append(_ORDER_BY_ENTITY_TABLE);
10168                                    }
10169    
10170                                    query.append(orderByConditionFields[i]);
10171    
10172                                    if ((i + 1) < orderByConditionFields.length) {
10173                                            if (orderByComparator.isAscending() ^ previous) {
10174                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10175                                            }
10176                                            else {
10177                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10178                                            }
10179                                    }
10180                                    else {
10181                                            if (orderByComparator.isAscending() ^ previous) {
10182                                                    query.append(WHERE_GREATER_THAN);
10183                                            }
10184                                            else {
10185                                                    query.append(WHERE_LESSER_THAN);
10186                                            }
10187                                    }
10188                            }
10189    
10190                            query.append(ORDER_BY_CLAUSE);
10191    
10192                            String[] orderByFields = orderByComparator.getOrderByFields();
10193    
10194                            for (int i = 0; i < orderByFields.length; i++) {
10195                                    if (getDB().isSupportsInlineDistinct()) {
10196                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10197                                    }
10198                                    else {
10199                                            query.append(_ORDER_BY_ENTITY_TABLE);
10200                                    }
10201    
10202                                    query.append(orderByFields[i]);
10203    
10204                                    if ((i + 1) < orderByFields.length) {
10205                                            if (orderByComparator.isAscending() ^ previous) {
10206                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10207                                            }
10208                                            else {
10209                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10210                                            }
10211                                    }
10212                                    else {
10213                                            if (orderByComparator.isAscending() ^ previous) {
10214                                                    query.append(ORDER_BY_ASC);
10215                                            }
10216                                            else {
10217                                                    query.append(ORDER_BY_DESC);
10218                                            }
10219                                    }
10220                            }
10221                    }
10222                    else {
10223                            if (getDB().isSupportsInlineDistinct()) {
10224                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10225                            }
10226                            else {
10227                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10228                            }
10229                    }
10230    
10231                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10232                                    JournalArticle.class.getName(),
10233                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10234    
10235                    SQLQuery q = session.createSQLQuery(sql);
10236    
10237                    q.setFirstResult(0);
10238                    q.setMaxResults(2);
10239    
10240                    if (getDB().isSupportsInlineDistinct()) {
10241                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10242                    }
10243                    else {
10244                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10245                    }
10246    
10247                    QueryPos qPos = QueryPos.getInstance(q);
10248    
10249                    qPos.add(groupId);
10250    
10251                    if (bindArticleId) {
10252                            qPos.add(articleId);
10253                    }
10254    
10255                    if (orderByComparator != null) {
10256                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10257    
10258                            for (Object value : values) {
10259                                    qPos.add(value);
10260                            }
10261                    }
10262    
10263                    List<JournalArticle> list = q.list();
10264    
10265                    if (list.size() == 2) {
10266                            return list.get(1);
10267                    }
10268                    else {
10269                            return null;
10270                    }
10271            }
10272    
10273            /**
10274             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
10275             *
10276             * @param groupId the group ID
10277             * @param articleId the article ID
10278             * @throws SystemException if a system exception occurred
10279             */
10280            @Override
10281            public void removeByG_A(long groupId, String articleId)
10282                    throws SystemException {
10283                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
10284                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10285                            remove(journalArticle);
10286                    }
10287            }
10288    
10289            /**
10290             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
10291             *
10292             * @param groupId the group ID
10293             * @param articleId the article ID
10294             * @return the number of matching journal articles
10295             * @throws SystemException if a system exception occurred
10296             */
10297            @Override
10298            public int countByG_A(long groupId, String articleId)
10299                    throws SystemException {
10300                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
10301    
10302                    Object[] finderArgs = new Object[] { groupId, articleId };
10303    
10304                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10305                                    this);
10306    
10307                    if (count == null) {
10308                            StringBundler query = new StringBundler(3);
10309    
10310                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10311    
10312                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10313    
10314                            boolean bindArticleId = false;
10315    
10316                            if (articleId == null) {
10317                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10318                            }
10319                            else if (articleId.equals(StringPool.BLANK)) {
10320                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10321                            }
10322                            else {
10323                                    bindArticleId = true;
10324    
10325                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10326                            }
10327    
10328                            String sql = query.toString();
10329    
10330                            Session session = null;
10331    
10332                            try {
10333                                    session = openSession();
10334    
10335                                    Query q = session.createQuery(sql);
10336    
10337                                    QueryPos qPos = QueryPos.getInstance(q);
10338    
10339                                    qPos.add(groupId);
10340    
10341                                    if (bindArticleId) {
10342                                            qPos.add(articleId);
10343                                    }
10344    
10345                                    count = (Long)q.uniqueResult();
10346    
10347                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10348                            }
10349                            catch (Exception e) {
10350                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10351    
10352                                    throw processException(e);
10353                            }
10354                            finally {
10355                                    closeSession(session);
10356                            }
10357                    }
10358    
10359                    return count.intValue();
10360            }
10361    
10362            /**
10363             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
10364             *
10365             * @param groupId the group ID
10366             * @param articleId the article ID
10367             * @return the number of matching journal articles that the user has permission to view
10368             * @throws SystemException if a system exception occurred
10369             */
10370            @Override
10371            public int filterCountByG_A(long groupId, String articleId)
10372                    throws SystemException {
10373                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10374                            return countByG_A(groupId, articleId);
10375                    }
10376    
10377                    StringBundler query = new StringBundler(3);
10378    
10379                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10380    
10381                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10382    
10383                    boolean bindArticleId = false;
10384    
10385                    if (articleId == null) {
10386                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10387                    }
10388                    else if (articleId.equals(StringPool.BLANK)) {
10389                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10390                    }
10391                    else {
10392                            bindArticleId = true;
10393    
10394                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10395                    }
10396    
10397                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10398                                    JournalArticle.class.getName(),
10399                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10400    
10401                    Session session = null;
10402    
10403                    try {
10404                            session = openSession();
10405    
10406                            SQLQuery q = session.createSQLQuery(sql);
10407    
10408                            q.addScalar(COUNT_COLUMN_NAME,
10409                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10410    
10411                            QueryPos qPos = QueryPos.getInstance(q);
10412    
10413                            qPos.add(groupId);
10414    
10415                            if (bindArticleId) {
10416                                    qPos.add(articleId);
10417                            }
10418    
10419                            Long count = (Long)q.uniqueResult();
10420    
10421                            return count.intValue();
10422                    }
10423                    catch (Exception e) {
10424                            throw processException(e);
10425                    }
10426                    finally {
10427                            closeSession(session);
10428                    }
10429            }
10430    
10431            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
10432            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
10433            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
10434            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
10435            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10436                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10437                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10438                            "findByG_UT",
10439                            new String[] {
10440                                    Long.class.getName(), String.class.getName(),
10441                                    
10442                            Integer.class.getName(), Integer.class.getName(),
10443                                    OrderByComparator.class.getName()
10444                            });
10445            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10446                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10447                            JournalArticleImpl.class,
10448                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
10449                            new String[] { Long.class.getName(), String.class.getName() },
10450                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10451                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
10452                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10453                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10454            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10455                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10456                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
10457                            new String[] { Long.class.getName(), String.class.getName() });
10458    
10459            /**
10460             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
10461             *
10462             * @param groupId the group ID
10463             * @param urlTitle the url title
10464             * @return the matching journal articles
10465             * @throws SystemException if a system exception occurred
10466             */
10467            @Override
10468            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
10469                    throws SystemException {
10470                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10471                            QueryUtil.ALL_POS, null);
10472            }
10473    
10474            /**
10475             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10476             *
10477             * <p>
10478             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10479             * </p>
10480             *
10481             * @param groupId the group ID
10482             * @param urlTitle the url title
10483             * @param start the lower bound of the range of journal articles
10484             * @param end the upper bound of the range of journal articles (not inclusive)
10485             * @return the range of matching journal articles
10486             * @throws SystemException if a system exception occurred
10487             */
10488            @Override
10489            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10490                    int start, int end) throws SystemException {
10491                    return findByG_UT(groupId, urlTitle, start, end, null);
10492            }
10493    
10494            /**
10495             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10496             *
10497             * <p>
10498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10499             * </p>
10500             *
10501             * @param groupId the group ID
10502             * @param urlTitle the url title
10503             * @param start the lower bound of the range of journal articles
10504             * @param end the upper bound of the range of journal articles (not inclusive)
10505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10506             * @return the ordered range of matching journal articles
10507             * @throws SystemException if a system exception occurred
10508             */
10509            @Override
10510            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10511                    int start, int end, OrderByComparator orderByComparator)
10512                    throws SystemException {
10513                    boolean pagination = true;
10514                    FinderPath finderPath = null;
10515                    Object[] finderArgs = null;
10516    
10517                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10518                                    (orderByComparator == null)) {
10519                            pagination = false;
10520                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
10521                            finderArgs = new Object[] { groupId, urlTitle };
10522                    }
10523                    else {
10524                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
10525                            finderArgs = new Object[] {
10526                                            groupId, urlTitle,
10527                                            
10528                                            start, end, orderByComparator
10529                                    };
10530                    }
10531    
10532                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10533                                    finderArgs, this);
10534    
10535                    if ((list != null) && !list.isEmpty()) {
10536                            for (JournalArticle journalArticle : list) {
10537                                    if ((groupId != journalArticle.getGroupId()) ||
10538                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
10539                                            list = null;
10540    
10541                                            break;
10542                                    }
10543                            }
10544                    }
10545    
10546                    if (list == null) {
10547                            StringBundler query = null;
10548    
10549                            if (orderByComparator != null) {
10550                                    query = new StringBundler(4 +
10551                                                    (orderByComparator.getOrderByFields().length * 3));
10552                            }
10553                            else {
10554                                    query = new StringBundler(4);
10555                            }
10556    
10557                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10558    
10559                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10560    
10561                            boolean bindUrlTitle = false;
10562    
10563                            if (urlTitle == null) {
10564                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10565                            }
10566                            else if (urlTitle.equals(StringPool.BLANK)) {
10567                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10568                            }
10569                            else {
10570                                    bindUrlTitle = true;
10571    
10572                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10573                            }
10574    
10575                            if (orderByComparator != null) {
10576                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10577                                            orderByComparator);
10578                            }
10579                            else
10580                             if (pagination) {
10581                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10582                            }
10583    
10584                            String sql = query.toString();
10585    
10586                            Session session = null;
10587    
10588                            try {
10589                                    session = openSession();
10590    
10591                                    Query q = session.createQuery(sql);
10592    
10593                                    QueryPos qPos = QueryPos.getInstance(q);
10594    
10595                                    qPos.add(groupId);
10596    
10597                                    if (bindUrlTitle) {
10598                                            qPos.add(urlTitle);
10599                                    }
10600    
10601                                    if (!pagination) {
10602                                            list = (List<JournalArticle>)QueryUtil.list(q,
10603                                                            getDialect(), start, end, false);
10604    
10605                                            Collections.sort(list);
10606    
10607                                            list = new UnmodifiableList<JournalArticle>(list);
10608                                    }
10609                                    else {
10610                                            list = (List<JournalArticle>)QueryUtil.list(q,
10611                                                            getDialect(), start, end);
10612                                    }
10613    
10614                                    cacheResult(list);
10615    
10616                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10617                            }
10618                            catch (Exception e) {
10619                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10620    
10621                                    throw processException(e);
10622                            }
10623                            finally {
10624                                    closeSession(session);
10625                            }
10626                    }
10627    
10628                    return list;
10629            }
10630    
10631            /**
10632             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10633             *
10634             * @param groupId the group ID
10635             * @param urlTitle the url title
10636             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10637             * @return the first matching journal article
10638             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10639             * @throws SystemException if a system exception occurred
10640             */
10641            @Override
10642            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
10643                    OrderByComparator orderByComparator)
10644                    throws NoSuchArticleException, SystemException {
10645                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
10646                                    orderByComparator);
10647    
10648                    if (journalArticle != null) {
10649                            return journalArticle;
10650                    }
10651    
10652                    StringBundler msg = new StringBundler(6);
10653    
10654                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10655    
10656                    msg.append("groupId=");
10657                    msg.append(groupId);
10658    
10659                    msg.append(", urlTitle=");
10660                    msg.append(urlTitle);
10661    
10662                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10663    
10664                    throw new NoSuchArticleException(msg.toString());
10665            }
10666    
10667            /**
10668             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10669             *
10670             * @param groupId the group ID
10671             * @param urlTitle the url title
10672             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10673             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10674             * @throws SystemException if a system exception occurred
10675             */
10676            @Override
10677            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
10678                    OrderByComparator orderByComparator) throws SystemException {
10679                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
10680                                    orderByComparator);
10681    
10682                    if (!list.isEmpty()) {
10683                            return list.get(0);
10684                    }
10685    
10686                    return null;
10687            }
10688    
10689            /**
10690             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10691             *
10692             * @param groupId the group ID
10693             * @param urlTitle the url title
10694             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10695             * @return the last matching journal article
10696             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10697             * @throws SystemException if a system exception occurred
10698             */
10699            @Override
10700            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
10701                    OrderByComparator orderByComparator)
10702                    throws NoSuchArticleException, SystemException {
10703                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
10704                                    orderByComparator);
10705    
10706                    if (journalArticle != null) {
10707                            return journalArticle;
10708                    }
10709    
10710                    StringBundler msg = new StringBundler(6);
10711    
10712                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10713    
10714                    msg.append("groupId=");
10715                    msg.append(groupId);
10716    
10717                    msg.append(", urlTitle=");
10718                    msg.append(urlTitle);
10719    
10720                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10721    
10722                    throw new NoSuchArticleException(msg.toString());
10723            }
10724    
10725            /**
10726             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10727             *
10728             * @param groupId the group ID
10729             * @param urlTitle the url title
10730             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10731             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10732             * @throws SystemException if a system exception occurred
10733             */
10734            @Override
10735            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
10736                    OrderByComparator orderByComparator) throws SystemException {
10737                    int count = countByG_UT(groupId, urlTitle);
10738    
10739                    if (count == 0) {
10740                            return null;
10741                    }
10742    
10743                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
10744                                    count, orderByComparator);
10745    
10746                    if (!list.isEmpty()) {
10747                            return list.get(0);
10748                    }
10749    
10750                    return null;
10751            }
10752    
10753            /**
10754             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10755             *
10756             * @param id the primary key of the current journal article
10757             * @param groupId the group ID
10758             * @param urlTitle the url title
10759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10760             * @return the previous, current, and next journal article
10761             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10762             * @throws SystemException if a system exception occurred
10763             */
10764            @Override
10765            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
10766                    String urlTitle, OrderByComparator orderByComparator)
10767                    throws NoSuchArticleException, SystemException {
10768                    JournalArticle journalArticle = findByPrimaryKey(id);
10769    
10770                    Session session = null;
10771    
10772                    try {
10773                            session = openSession();
10774    
10775                            JournalArticle[] array = new JournalArticleImpl[3];
10776    
10777                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10778                                            urlTitle, orderByComparator, true);
10779    
10780                            array[1] = journalArticle;
10781    
10782                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10783                                            urlTitle, orderByComparator, false);
10784    
10785                            return array;
10786                    }
10787                    catch (Exception e) {
10788                            throw processException(e);
10789                    }
10790                    finally {
10791                            closeSession(session);
10792                    }
10793            }
10794    
10795            protected JournalArticle getByG_UT_PrevAndNext(Session session,
10796                    JournalArticle journalArticle, long groupId, String urlTitle,
10797                    OrderByComparator orderByComparator, boolean previous) {
10798                    StringBundler query = null;
10799    
10800                    if (orderByComparator != null) {
10801                            query = new StringBundler(6 +
10802                                            (orderByComparator.getOrderByFields().length * 6));
10803                    }
10804                    else {
10805                            query = new StringBundler(3);
10806                    }
10807    
10808                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10809    
10810                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10811    
10812                    boolean bindUrlTitle = false;
10813    
10814                    if (urlTitle == null) {
10815                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10816                    }
10817                    else if (urlTitle.equals(StringPool.BLANK)) {
10818                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10819                    }
10820                    else {
10821                            bindUrlTitle = true;
10822    
10823                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10824                    }
10825    
10826                    if (orderByComparator != null) {
10827                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10828    
10829                            if (orderByConditionFields.length > 0) {
10830                                    query.append(WHERE_AND);
10831                            }
10832    
10833                            for (int i = 0; i < orderByConditionFields.length; i++) {
10834                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10835                                    query.append(orderByConditionFields[i]);
10836    
10837                                    if ((i + 1) < orderByConditionFields.length) {
10838                                            if (orderByComparator.isAscending() ^ previous) {
10839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10840                                            }
10841                                            else {
10842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10843                                            }
10844                                    }
10845                                    else {
10846                                            if (orderByComparator.isAscending() ^ previous) {
10847                                                    query.append(WHERE_GREATER_THAN);
10848                                            }
10849                                            else {
10850                                                    query.append(WHERE_LESSER_THAN);
10851                                            }
10852                                    }
10853                            }
10854    
10855                            query.append(ORDER_BY_CLAUSE);
10856    
10857                            String[] orderByFields = orderByComparator.getOrderByFields();
10858    
10859                            for (int i = 0; i < orderByFields.length; i++) {
10860                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10861                                    query.append(orderByFields[i]);
10862    
10863                                    if ((i + 1) < orderByFields.length) {
10864                                            if (orderByComparator.isAscending() ^ previous) {
10865                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10866                                            }
10867                                            else {
10868                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10869                                            }
10870                                    }
10871                                    else {
10872                                            if (orderByComparator.isAscending() ^ previous) {
10873                                                    query.append(ORDER_BY_ASC);
10874                                            }
10875                                            else {
10876                                                    query.append(ORDER_BY_DESC);
10877                                            }
10878                                    }
10879                            }
10880                    }
10881                    else {
10882                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10883                    }
10884    
10885                    String sql = query.toString();
10886    
10887                    Query q = session.createQuery(sql);
10888    
10889                    q.setFirstResult(0);
10890                    q.setMaxResults(2);
10891    
10892                    QueryPos qPos = QueryPos.getInstance(q);
10893    
10894                    qPos.add(groupId);
10895    
10896                    if (bindUrlTitle) {
10897                            qPos.add(urlTitle);
10898                    }
10899    
10900                    if (orderByComparator != null) {
10901                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10902    
10903                            for (Object value : values) {
10904                                    qPos.add(value);
10905                            }
10906                    }
10907    
10908                    List<JournalArticle> list = q.list();
10909    
10910                    if (list.size() == 2) {
10911                            return list.get(1);
10912                    }
10913                    else {
10914                            return null;
10915                    }
10916            }
10917    
10918            /**
10919             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10920             *
10921             * @param groupId the group ID
10922             * @param urlTitle the url title
10923             * @return the matching journal articles that the user has permission to view
10924             * @throws SystemException if a system exception occurred
10925             */
10926            @Override
10927            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
10928                    throws SystemException {
10929                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10930                            QueryUtil.ALL_POS, null);
10931            }
10932    
10933            /**
10934             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10935             *
10936             * <p>
10937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10938             * </p>
10939             *
10940             * @param groupId the group ID
10941             * @param urlTitle the url title
10942             * @param start the lower bound of the range of journal articles
10943             * @param end the upper bound of the range of journal articles (not inclusive)
10944             * @return the range of matching journal articles that the user has permission to view
10945             * @throws SystemException if a system exception occurred
10946             */
10947            @Override
10948            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10949                    int start, int end) throws SystemException {
10950                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
10951            }
10952    
10953            /**
10954             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
10955             *
10956             * <p>
10957             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10958             * </p>
10959             *
10960             * @param groupId the group ID
10961             * @param urlTitle the url title
10962             * @param start the lower bound of the range of journal articles
10963             * @param end the upper bound of the range of journal articles (not inclusive)
10964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10965             * @return the ordered range of matching journal articles that the user has permission to view
10966             * @throws SystemException if a system exception occurred
10967             */
10968            @Override
10969            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10970                    int start, int end, OrderByComparator orderByComparator)
10971                    throws SystemException {
10972                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10973                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
10974                    }
10975    
10976                    StringBundler query = null;
10977    
10978                    if (orderByComparator != null) {
10979                            query = new StringBundler(4 +
10980                                            (orderByComparator.getOrderByFields().length * 3));
10981                    }
10982                    else {
10983                            query = new StringBundler(4);
10984                    }
10985    
10986                    if (getDB().isSupportsInlineDistinct()) {
10987                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10988                    }
10989                    else {
10990                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10991                    }
10992    
10993                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10994    
10995                    boolean bindUrlTitle = false;
10996    
10997                    if (urlTitle == null) {
10998                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10999                    }
11000                    else if (urlTitle.equals(StringPool.BLANK)) {
11001                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11002                    }
11003                    else {
11004                            bindUrlTitle = true;
11005    
11006                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11007                    }
11008    
11009                    if (!getDB().isSupportsInlineDistinct()) {
11010                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11011                    }
11012    
11013                    if (orderByComparator != null) {
11014                            if (getDB().isSupportsInlineDistinct()) {
11015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11016                                            orderByComparator, true);
11017                            }
11018                            else {
11019                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11020                                            orderByComparator, true);
11021                            }
11022                    }
11023                    else {
11024                            if (getDB().isSupportsInlineDistinct()) {
11025                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11026                            }
11027                            else {
11028                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11029                            }
11030                    }
11031    
11032                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11033                                    JournalArticle.class.getName(),
11034                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11035    
11036                    Session session = null;
11037    
11038                    try {
11039                            session = openSession();
11040    
11041                            SQLQuery q = session.createSQLQuery(sql);
11042    
11043                            if (getDB().isSupportsInlineDistinct()) {
11044                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11045                            }
11046                            else {
11047                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11048                            }
11049    
11050                            QueryPos qPos = QueryPos.getInstance(q);
11051    
11052                            qPos.add(groupId);
11053    
11054                            if (bindUrlTitle) {
11055                                    qPos.add(urlTitle);
11056                            }
11057    
11058                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11059                                    end);
11060                    }
11061                    catch (Exception e) {
11062                            throw processException(e);
11063                    }
11064                    finally {
11065                            closeSession(session);
11066                    }
11067            }
11068    
11069            /**
11070             * 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;.
11071             *
11072             * @param id the primary key of the current journal article
11073             * @param groupId the group ID
11074             * @param urlTitle the url title
11075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11076             * @return the previous, current, and next journal article
11077             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11078             * @throws SystemException if a system exception occurred
11079             */
11080            @Override
11081            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
11082                    String urlTitle, OrderByComparator orderByComparator)
11083                    throws NoSuchArticleException, SystemException {
11084                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11085                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
11086                                    orderByComparator);
11087                    }
11088    
11089                    JournalArticle journalArticle = findByPrimaryKey(id);
11090    
11091                    Session session = null;
11092    
11093                    try {
11094                            session = openSession();
11095    
11096                            JournalArticle[] array = new JournalArticleImpl[3];
11097    
11098                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
11099                                            groupId, urlTitle, orderByComparator, true);
11100    
11101                            array[1] = journalArticle;
11102    
11103                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
11104                                            groupId, urlTitle, orderByComparator, false);
11105    
11106                            return array;
11107                    }
11108                    catch (Exception e) {
11109                            throw processException(e);
11110                    }
11111                    finally {
11112                            closeSession(session);
11113                    }
11114            }
11115    
11116            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
11117                    JournalArticle journalArticle, long groupId, String urlTitle,
11118                    OrderByComparator orderByComparator, boolean previous) {
11119                    StringBundler query = null;
11120    
11121                    if (orderByComparator != null) {
11122                            query = new StringBundler(6 +
11123                                            (orderByComparator.getOrderByFields().length * 6));
11124                    }
11125                    else {
11126                            query = new StringBundler(3);
11127                    }
11128    
11129                    if (getDB().isSupportsInlineDistinct()) {
11130                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11131                    }
11132                    else {
11133                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11134                    }
11135    
11136                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11137    
11138                    boolean bindUrlTitle = false;
11139    
11140                    if (urlTitle == null) {
11141                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11142                    }
11143                    else if (urlTitle.equals(StringPool.BLANK)) {
11144                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11145                    }
11146                    else {
11147                            bindUrlTitle = true;
11148    
11149                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11150                    }
11151    
11152                    if (!getDB().isSupportsInlineDistinct()) {
11153                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11154                    }
11155    
11156                    if (orderByComparator != null) {
11157                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11158    
11159                            if (orderByConditionFields.length > 0) {
11160                                    query.append(WHERE_AND);
11161                            }
11162    
11163                            for (int i = 0; i < orderByConditionFields.length; i++) {
11164                                    if (getDB().isSupportsInlineDistinct()) {
11165                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11166                                    }
11167                                    else {
11168                                            query.append(_ORDER_BY_ENTITY_TABLE);
11169                                    }
11170    
11171                                    query.append(orderByConditionFields[i]);
11172    
11173                                    if ((i + 1) < orderByConditionFields.length) {
11174                                            if (orderByComparator.isAscending() ^ previous) {
11175                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11176                                            }
11177                                            else {
11178                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11179                                            }
11180                                    }
11181                                    else {
11182                                            if (orderByComparator.isAscending() ^ previous) {
11183                                                    query.append(WHERE_GREATER_THAN);
11184                                            }
11185                                            else {
11186                                                    query.append(WHERE_LESSER_THAN);
11187                                            }
11188                                    }
11189                            }
11190    
11191                            query.append(ORDER_BY_CLAUSE);
11192    
11193                            String[] orderByFields = orderByComparator.getOrderByFields();
11194    
11195                            for (int i = 0; i < orderByFields.length; i++) {
11196                                    if (getDB().isSupportsInlineDistinct()) {
11197                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11198                                    }
11199                                    else {
11200                                            query.append(_ORDER_BY_ENTITY_TABLE);
11201                                    }
11202    
11203                                    query.append(orderByFields[i]);
11204    
11205                                    if ((i + 1) < orderByFields.length) {
11206                                            if (orderByComparator.isAscending() ^ previous) {
11207                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11208                                            }
11209                                            else {
11210                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11211                                            }
11212                                    }
11213                                    else {
11214                                            if (orderByComparator.isAscending() ^ previous) {
11215                                                    query.append(ORDER_BY_ASC);
11216                                            }
11217                                            else {
11218                                                    query.append(ORDER_BY_DESC);
11219                                            }
11220                                    }
11221                            }
11222                    }
11223                    else {
11224                            if (getDB().isSupportsInlineDistinct()) {
11225                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11226                            }
11227                            else {
11228                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11229                            }
11230                    }
11231    
11232                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11233                                    JournalArticle.class.getName(),
11234                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11235    
11236                    SQLQuery q = session.createSQLQuery(sql);
11237    
11238                    q.setFirstResult(0);
11239                    q.setMaxResults(2);
11240    
11241                    if (getDB().isSupportsInlineDistinct()) {
11242                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11243                    }
11244                    else {
11245                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11246                    }
11247    
11248                    QueryPos qPos = QueryPos.getInstance(q);
11249    
11250                    qPos.add(groupId);
11251    
11252                    if (bindUrlTitle) {
11253                            qPos.add(urlTitle);
11254                    }
11255    
11256                    if (orderByComparator != null) {
11257                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11258    
11259                            for (Object value : values) {
11260                                    qPos.add(value);
11261                            }
11262                    }
11263    
11264                    List<JournalArticle> list = q.list();
11265    
11266                    if (list.size() == 2) {
11267                            return list.get(1);
11268                    }
11269                    else {
11270                            return null;
11271                    }
11272            }
11273    
11274            /**
11275             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
11276             *
11277             * @param groupId the group ID
11278             * @param urlTitle the url title
11279             * @throws SystemException if a system exception occurred
11280             */
11281            @Override
11282            public void removeByG_UT(long groupId, String urlTitle)
11283                    throws SystemException {
11284                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
11285                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11286                            remove(journalArticle);
11287                    }
11288            }
11289    
11290            /**
11291             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
11292             *
11293             * @param groupId the group ID
11294             * @param urlTitle the url title
11295             * @return the number of matching journal articles
11296             * @throws SystemException if a system exception occurred
11297             */
11298            @Override
11299            public int countByG_UT(long groupId, String urlTitle)
11300                    throws SystemException {
11301                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
11302    
11303                    Object[] finderArgs = new Object[] { groupId, urlTitle };
11304    
11305                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11306                                    this);
11307    
11308                    if (count == null) {
11309                            StringBundler query = new StringBundler(3);
11310    
11311                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11312    
11313                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11314    
11315                            boolean bindUrlTitle = false;
11316    
11317                            if (urlTitle == null) {
11318                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11319                            }
11320                            else if (urlTitle.equals(StringPool.BLANK)) {
11321                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11322                            }
11323                            else {
11324                                    bindUrlTitle = true;
11325    
11326                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11327                            }
11328    
11329                            String sql = query.toString();
11330    
11331                            Session session = null;
11332    
11333                            try {
11334                                    session = openSession();
11335    
11336                                    Query q = session.createQuery(sql);
11337    
11338                                    QueryPos qPos = QueryPos.getInstance(q);
11339    
11340                                    qPos.add(groupId);
11341    
11342                                    if (bindUrlTitle) {
11343                                            qPos.add(urlTitle);
11344                                    }
11345    
11346                                    count = (Long)q.uniqueResult();
11347    
11348                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11349                            }
11350                            catch (Exception e) {
11351                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11352    
11353                                    throw processException(e);
11354                            }
11355                            finally {
11356                                    closeSession(session);
11357                            }
11358                    }
11359    
11360                    return count.intValue();
11361            }
11362    
11363            /**
11364             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
11365             *
11366             * @param groupId the group ID
11367             * @param urlTitle the url title
11368             * @return the number of matching journal articles that the user has permission to view
11369             * @throws SystemException if a system exception occurred
11370             */
11371            @Override
11372            public int filterCountByG_UT(long groupId, String urlTitle)
11373                    throws SystemException {
11374                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11375                            return countByG_UT(groupId, urlTitle);
11376                    }
11377    
11378                    StringBundler query = new StringBundler(3);
11379    
11380                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11381    
11382                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11383    
11384                    boolean bindUrlTitle = false;
11385    
11386                    if (urlTitle == null) {
11387                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11388                    }
11389                    else if (urlTitle.equals(StringPool.BLANK)) {
11390                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11391                    }
11392                    else {
11393                            bindUrlTitle = true;
11394    
11395                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11396                    }
11397    
11398                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11399                                    JournalArticle.class.getName(),
11400                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11401    
11402                    Session session = null;
11403    
11404                    try {
11405                            session = openSession();
11406    
11407                            SQLQuery q = session.createSQLQuery(sql);
11408    
11409                            q.addScalar(COUNT_COLUMN_NAME,
11410                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11411    
11412                            QueryPos qPos = QueryPos.getInstance(q);
11413    
11414                            qPos.add(groupId);
11415    
11416                            if (bindUrlTitle) {
11417                                    qPos.add(urlTitle);
11418                            }
11419    
11420                            Long count = (Long)q.uniqueResult();
11421    
11422                            return count.intValue();
11423                    }
11424                    catch (Exception e) {
11425                            throw processException(e);
11426                    }
11427                    finally {
11428                            closeSession(session);
11429                    }
11430            }
11431    
11432            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
11433            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
11434            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
11435            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
11436            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11437                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11438                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11439                            "findByG_S",
11440                            new String[] {
11441                                    Long.class.getName(), String.class.getName(),
11442                                    
11443                            Integer.class.getName(), Integer.class.getName(),
11444                                    OrderByComparator.class.getName()
11445                            });
11446            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11447                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11448                            JournalArticleImpl.class,
11449                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
11450                            new String[] { Long.class.getName(), String.class.getName() },
11451                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11452                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
11453                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11454                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11455            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11456                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11457                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
11458                            new String[] { Long.class.getName(), String.class.getName() });
11459    
11460            /**
11461             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
11462             *
11463             * @param groupId the group ID
11464             * @param structureId the structure ID
11465             * @return the matching journal articles
11466             * @throws SystemException if a system exception occurred
11467             */
11468            @Override
11469            public List<JournalArticle> findByG_S(long groupId, String structureId)
11470                    throws SystemException {
11471                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
11472                            QueryUtil.ALL_POS, null);
11473            }
11474    
11475            /**
11476             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
11477             *
11478             * <p>
11479             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11480             * </p>
11481             *
11482             * @param groupId the group ID
11483             * @param structureId the structure ID
11484             * @param start the lower bound of the range of journal articles
11485             * @param end the upper bound of the range of journal articles (not inclusive)
11486             * @return the range of matching journal articles
11487             * @throws SystemException if a system exception occurred
11488             */
11489            @Override
11490            public List<JournalArticle> findByG_S(long groupId, String structureId,
11491                    int start, int end) throws SystemException {
11492                    return findByG_S(groupId, structureId, start, end, null);
11493            }
11494    
11495            /**
11496             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
11497             *
11498             * <p>
11499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11500             * </p>
11501             *
11502             * @param groupId the group ID
11503             * @param structureId the structure ID
11504             * @param start the lower bound of the range of journal articles
11505             * @param end the upper bound of the range of journal articles (not inclusive)
11506             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11507             * @return the ordered range of matching journal articles
11508             * @throws SystemException if a system exception occurred
11509             */
11510            @Override
11511            public List<JournalArticle> findByG_S(long groupId, String structureId,
11512                    int start, int end, OrderByComparator orderByComparator)
11513                    throws SystemException {
11514                    boolean pagination = true;
11515                    FinderPath finderPath = null;
11516                    Object[] finderArgs = null;
11517    
11518                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11519                                    (orderByComparator == null)) {
11520                            pagination = false;
11521                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
11522                            finderArgs = new Object[] { groupId, structureId };
11523                    }
11524                    else {
11525                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
11526                            finderArgs = new Object[] {
11527                                            groupId, structureId,
11528                                            
11529                                            start, end, orderByComparator
11530                                    };
11531                    }
11532    
11533                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11534                                    finderArgs, this);
11535    
11536                    if ((list != null) && !list.isEmpty()) {
11537                            for (JournalArticle journalArticle : list) {
11538                                    if ((groupId != journalArticle.getGroupId()) ||
11539                                                    !Validator.equals(structureId,
11540                                                            journalArticle.getStructureId())) {
11541                                            list = null;
11542    
11543                                            break;
11544                                    }
11545                            }
11546                    }
11547    
11548                    if (list == null) {
11549                            StringBundler query = null;
11550    
11551                            if (orderByComparator != null) {
11552                                    query = new StringBundler(4 +
11553                                                    (orderByComparator.getOrderByFields().length * 3));
11554                            }
11555                            else {
11556                                    query = new StringBundler(4);
11557                            }
11558    
11559                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11560    
11561                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11562    
11563                            boolean bindStructureId = false;
11564    
11565                            if (structureId == null) {
11566                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11567                            }
11568                            else if (structureId.equals(StringPool.BLANK)) {
11569                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11570                            }
11571                            else {
11572                                    bindStructureId = true;
11573    
11574                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11575                            }
11576    
11577                            if (orderByComparator != null) {
11578                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11579                                            orderByComparator);
11580                            }
11581                            else
11582                             if (pagination) {
11583                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11584                            }
11585    
11586                            String sql = query.toString();
11587    
11588                            Session session = null;
11589    
11590                            try {
11591                                    session = openSession();
11592    
11593                                    Query q = session.createQuery(sql);
11594    
11595                                    QueryPos qPos = QueryPos.getInstance(q);
11596    
11597                                    qPos.add(groupId);
11598    
11599                                    if (bindStructureId) {
11600                                            qPos.add(structureId);
11601                                    }
11602    
11603                                    if (!pagination) {
11604                                            list = (List<JournalArticle>)QueryUtil.list(q,
11605                                                            getDialect(), start, end, false);
11606    
11607                                            Collections.sort(list);
11608    
11609                                            list = new UnmodifiableList<JournalArticle>(list);
11610                                    }
11611                                    else {
11612                                            list = (List<JournalArticle>)QueryUtil.list(q,
11613                                                            getDialect(), start, end);
11614                                    }
11615    
11616                                    cacheResult(list);
11617    
11618                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11619                            }
11620                            catch (Exception e) {
11621                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11622    
11623                                    throw processException(e);
11624                            }
11625                            finally {
11626                                    closeSession(session);
11627                            }
11628                    }
11629    
11630                    return list;
11631            }
11632    
11633            /**
11634             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11635             *
11636             * @param groupId the group ID
11637             * @param structureId the structure ID
11638             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11639             * @return the first matching journal article
11640             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11641             * @throws SystemException if a system exception occurred
11642             */
11643            @Override
11644            public JournalArticle findByG_S_First(long groupId, String structureId,
11645                    OrderByComparator orderByComparator)
11646                    throws NoSuchArticleException, SystemException {
11647                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
11648                                    orderByComparator);
11649    
11650                    if (journalArticle != null) {
11651                            return journalArticle;
11652                    }
11653    
11654                    StringBundler msg = new StringBundler(6);
11655    
11656                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11657    
11658                    msg.append("groupId=");
11659                    msg.append(groupId);
11660    
11661                    msg.append(", structureId=");
11662                    msg.append(structureId);
11663    
11664                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11665    
11666                    throw new NoSuchArticleException(msg.toString());
11667            }
11668    
11669            /**
11670             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11671             *
11672             * @param groupId the group ID
11673             * @param structureId the structure ID
11674             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11675             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11676             * @throws SystemException if a system exception occurred
11677             */
11678            @Override
11679            public JournalArticle fetchByG_S_First(long groupId, String structureId,
11680                    OrderByComparator orderByComparator) throws SystemException {
11681                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
11682                                    orderByComparator);
11683    
11684                    if (!list.isEmpty()) {
11685                            return list.get(0);
11686                    }
11687    
11688                    return null;
11689            }
11690    
11691            /**
11692             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11693             *
11694             * @param groupId the group ID
11695             * @param structureId the structure ID
11696             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11697             * @return the last matching journal article
11698             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11699             * @throws SystemException if a system exception occurred
11700             */
11701            @Override
11702            public JournalArticle findByG_S_Last(long groupId, String structureId,
11703                    OrderByComparator orderByComparator)
11704                    throws NoSuchArticleException, SystemException {
11705                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
11706                                    orderByComparator);
11707    
11708                    if (journalArticle != null) {
11709                            return journalArticle;
11710                    }
11711    
11712                    StringBundler msg = new StringBundler(6);
11713    
11714                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11715    
11716                    msg.append("groupId=");
11717                    msg.append(groupId);
11718    
11719                    msg.append(", structureId=");
11720                    msg.append(structureId);
11721    
11722                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11723    
11724                    throw new NoSuchArticleException(msg.toString());
11725            }
11726    
11727            /**
11728             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11729             *
11730             * @param groupId the group ID
11731             * @param structureId the structure ID
11732             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11733             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11734             * @throws SystemException if a system exception occurred
11735             */
11736            @Override
11737            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
11738                    OrderByComparator orderByComparator) throws SystemException {
11739                    int count = countByG_S(groupId, structureId);
11740    
11741                    if (count == 0) {
11742                            return null;
11743                    }
11744    
11745                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
11746                                    count, orderByComparator);
11747    
11748                    if (!list.isEmpty()) {
11749                            return list.get(0);
11750                    }
11751    
11752                    return null;
11753            }
11754    
11755            /**
11756             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11757             *
11758             * @param id the primary key of the current journal article
11759             * @param groupId the group ID
11760             * @param structureId the structure ID
11761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11762             * @return the previous, current, and next journal article
11763             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11764             * @throws SystemException if a system exception occurred
11765             */
11766            @Override
11767            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
11768                    String structureId, OrderByComparator orderByComparator)
11769                    throws NoSuchArticleException, SystemException {
11770                    JournalArticle journalArticle = findByPrimaryKey(id);
11771    
11772                    Session session = null;
11773    
11774                    try {
11775                            session = openSession();
11776    
11777                            JournalArticle[] array = new JournalArticleImpl[3];
11778    
11779                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11780                                            structureId, orderByComparator, true);
11781    
11782                            array[1] = journalArticle;
11783    
11784                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11785                                            structureId, orderByComparator, false);
11786    
11787                            return array;
11788                    }
11789                    catch (Exception e) {
11790                            throw processException(e);
11791                    }
11792                    finally {
11793                            closeSession(session);
11794                    }
11795            }
11796    
11797            protected JournalArticle getByG_S_PrevAndNext(Session session,
11798                    JournalArticle journalArticle, long groupId, String structureId,
11799                    OrderByComparator orderByComparator, boolean previous) {
11800                    StringBundler query = null;
11801    
11802                    if (orderByComparator != null) {
11803                            query = new StringBundler(6 +
11804                                            (orderByComparator.getOrderByFields().length * 6));
11805                    }
11806                    else {
11807                            query = new StringBundler(3);
11808                    }
11809    
11810                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11811    
11812                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11813    
11814                    boolean bindStructureId = false;
11815    
11816                    if (structureId == null) {
11817                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11818                    }
11819                    else if (structureId.equals(StringPool.BLANK)) {
11820                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11821                    }
11822                    else {
11823                            bindStructureId = true;
11824    
11825                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11826                    }
11827    
11828                    if (orderByComparator != null) {
11829                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11830    
11831                            if (orderByConditionFields.length > 0) {
11832                                    query.append(WHERE_AND);
11833                            }
11834    
11835                            for (int i = 0; i < orderByConditionFields.length; i++) {
11836                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11837                                    query.append(orderByConditionFields[i]);
11838    
11839                                    if ((i + 1) < orderByConditionFields.length) {
11840                                            if (orderByComparator.isAscending() ^ previous) {
11841                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11842                                            }
11843                                            else {
11844                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11845                                            }
11846                                    }
11847                                    else {
11848                                            if (orderByComparator.isAscending() ^ previous) {
11849                                                    query.append(WHERE_GREATER_THAN);
11850                                            }
11851                                            else {
11852                                                    query.append(WHERE_LESSER_THAN);
11853                                            }
11854                                    }
11855                            }
11856    
11857                            query.append(ORDER_BY_CLAUSE);
11858    
11859                            String[] orderByFields = orderByComparator.getOrderByFields();
11860    
11861                            for (int i = 0; i < orderByFields.length; i++) {
11862                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11863                                    query.append(orderByFields[i]);
11864    
11865                                    if ((i + 1) < orderByFields.length) {
11866                                            if (orderByComparator.isAscending() ^ previous) {
11867                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11868                                            }
11869                                            else {
11870                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11871                                            }
11872                                    }
11873                                    else {
11874                                            if (orderByComparator.isAscending() ^ previous) {
11875                                                    query.append(ORDER_BY_ASC);
11876                                            }
11877                                            else {
11878                                                    query.append(ORDER_BY_DESC);
11879                                            }
11880                                    }
11881                            }
11882                    }
11883                    else {
11884                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11885                    }
11886    
11887                    String sql = query.toString();
11888    
11889                    Query q = session.createQuery(sql);
11890    
11891                    q.setFirstResult(0);
11892                    q.setMaxResults(2);
11893    
11894                    QueryPos qPos = QueryPos.getInstance(q);
11895    
11896                    qPos.add(groupId);
11897    
11898                    if (bindStructureId) {
11899                            qPos.add(structureId);
11900                    }
11901    
11902                    if (orderByComparator != null) {
11903                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11904    
11905                            for (Object value : values) {
11906                                    qPos.add(value);
11907                            }
11908                    }
11909    
11910                    List<JournalArticle> list = q.list();
11911    
11912                    if (list.size() == 2) {
11913                            return list.get(1);
11914                    }
11915                    else {
11916                            return null;
11917                    }
11918            }
11919    
11920            /**
11921             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11922             *
11923             * @param groupId the group ID
11924             * @param structureId the structure ID
11925             * @return the matching journal articles that the user has permission to view
11926             * @throws SystemException if a system exception occurred
11927             */
11928            @Override
11929            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
11930                    throws SystemException {
11931                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
11932                            QueryUtil.ALL_POS, null);
11933            }
11934    
11935            /**
11936             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11937             *
11938             * <p>
11939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11940             * </p>
11941             *
11942             * @param groupId the group ID
11943             * @param structureId the structure ID
11944             * @param start the lower bound of the range of journal articles
11945             * @param end the upper bound of the range of journal articles (not inclusive)
11946             * @return the range of matching journal articles that the user has permission to view
11947             * @throws SystemException if a system exception occurred
11948             */
11949            @Override
11950            public List<JournalArticle> filterFindByG_S(long groupId,
11951                    String structureId, int start, int end) throws SystemException {
11952                    return filterFindByG_S(groupId, structureId, start, end, null);
11953            }
11954    
11955            /**
11956             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
11957             *
11958             * <p>
11959             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11960             * </p>
11961             *
11962             * @param groupId the group ID
11963             * @param structureId the structure ID
11964             * @param start the lower bound of the range of journal articles
11965             * @param end the upper bound of the range of journal articles (not inclusive)
11966             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11967             * @return the ordered range of matching journal articles that the user has permission to view
11968             * @throws SystemException if a system exception occurred
11969             */
11970            @Override
11971            public List<JournalArticle> filterFindByG_S(long groupId,
11972                    String structureId, int start, int end,
11973                    OrderByComparator orderByComparator) throws SystemException {
11974                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11975                            return findByG_S(groupId, structureId, start, end, orderByComparator);
11976                    }
11977    
11978                    StringBundler query = null;
11979    
11980                    if (orderByComparator != null) {
11981                            query = new StringBundler(4 +
11982                                            (orderByComparator.getOrderByFields().length * 3));
11983                    }
11984                    else {
11985                            query = new StringBundler(4);
11986                    }
11987    
11988                    if (getDB().isSupportsInlineDistinct()) {
11989                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11990                    }
11991                    else {
11992                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11993                    }
11994    
11995                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11996    
11997                    boolean bindStructureId = false;
11998    
11999                    if (structureId == null) {
12000                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12001                    }
12002                    else if (structureId.equals(StringPool.BLANK)) {
12003                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12004                    }
12005                    else {
12006                            bindStructureId = true;
12007    
12008                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12009                    }
12010    
12011                    if (!getDB().isSupportsInlineDistinct()) {
12012                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12013                    }
12014    
12015                    if (orderByComparator != null) {
12016                            if (getDB().isSupportsInlineDistinct()) {
12017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12018                                            orderByComparator, true);
12019                            }
12020                            else {
12021                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12022                                            orderByComparator, true);
12023                            }
12024                    }
12025                    else {
12026                            if (getDB().isSupportsInlineDistinct()) {
12027                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12028                            }
12029                            else {
12030                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12031                            }
12032                    }
12033    
12034                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12035                                    JournalArticle.class.getName(),
12036                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12037    
12038                    Session session = null;
12039    
12040                    try {
12041                            session = openSession();
12042    
12043                            SQLQuery q = session.createSQLQuery(sql);
12044    
12045                            if (getDB().isSupportsInlineDistinct()) {
12046                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12047                            }
12048                            else {
12049                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12050                            }
12051    
12052                            QueryPos qPos = QueryPos.getInstance(q);
12053    
12054                            qPos.add(groupId);
12055    
12056                            if (bindStructureId) {
12057                                    qPos.add(structureId);
12058                            }
12059    
12060                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12061                                    end);
12062                    }
12063                    catch (Exception e) {
12064                            throw processException(e);
12065                    }
12066                    finally {
12067                            closeSession(session);
12068                    }
12069            }
12070    
12071            /**
12072             * 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;.
12073             *
12074             * @param id the primary key of the current journal article
12075             * @param groupId the group ID
12076             * @param structureId the structure ID
12077             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12078             * @return the previous, current, and next journal article
12079             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12080             * @throws SystemException if a system exception occurred
12081             */
12082            @Override
12083            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
12084                    String structureId, OrderByComparator orderByComparator)
12085                    throws NoSuchArticleException, SystemException {
12086                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12087                            return findByG_S_PrevAndNext(id, groupId, structureId,
12088                                    orderByComparator);
12089                    }
12090    
12091                    JournalArticle journalArticle = findByPrimaryKey(id);
12092    
12093                    Session session = null;
12094    
12095                    try {
12096                            session = openSession();
12097    
12098                            JournalArticle[] array = new JournalArticleImpl[3];
12099    
12100                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
12101                                            groupId, structureId, orderByComparator, true);
12102    
12103                            array[1] = journalArticle;
12104    
12105                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
12106                                            groupId, structureId, orderByComparator, false);
12107    
12108                            return array;
12109                    }
12110                    catch (Exception e) {
12111                            throw processException(e);
12112                    }
12113                    finally {
12114                            closeSession(session);
12115                    }
12116            }
12117    
12118            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
12119                    JournalArticle journalArticle, long groupId, String structureId,
12120                    OrderByComparator orderByComparator, boolean previous) {
12121                    StringBundler query = null;
12122    
12123                    if (orderByComparator != null) {
12124                            query = new StringBundler(6 +
12125                                            (orderByComparator.getOrderByFields().length * 6));
12126                    }
12127                    else {
12128                            query = new StringBundler(3);
12129                    }
12130    
12131                    if (getDB().isSupportsInlineDistinct()) {
12132                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12133                    }
12134                    else {
12135                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12136                    }
12137    
12138                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12139    
12140                    boolean bindStructureId = false;
12141    
12142                    if (structureId == null) {
12143                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12144                    }
12145                    else if (structureId.equals(StringPool.BLANK)) {
12146                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12147                    }
12148                    else {
12149                            bindStructureId = true;
12150    
12151                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12152                    }
12153    
12154                    if (!getDB().isSupportsInlineDistinct()) {
12155                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12156                    }
12157    
12158                    if (orderByComparator != null) {
12159                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12160    
12161                            if (orderByConditionFields.length > 0) {
12162                                    query.append(WHERE_AND);
12163                            }
12164    
12165                            for (int i = 0; i < orderByConditionFields.length; i++) {
12166                                    if (getDB().isSupportsInlineDistinct()) {
12167                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12168                                    }
12169                                    else {
12170                                            query.append(_ORDER_BY_ENTITY_TABLE);
12171                                    }
12172    
12173                                    query.append(orderByConditionFields[i]);
12174    
12175                                    if ((i + 1) < orderByConditionFields.length) {
12176                                            if (orderByComparator.isAscending() ^ previous) {
12177                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12178                                            }
12179                                            else {
12180                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12181                                            }
12182                                    }
12183                                    else {
12184                                            if (orderByComparator.isAscending() ^ previous) {
12185                                                    query.append(WHERE_GREATER_THAN);
12186                                            }
12187                                            else {
12188                                                    query.append(WHERE_LESSER_THAN);
12189                                            }
12190                                    }
12191                            }
12192    
12193                            query.append(ORDER_BY_CLAUSE);
12194    
12195                            String[] orderByFields = orderByComparator.getOrderByFields();
12196    
12197                            for (int i = 0; i < orderByFields.length; i++) {
12198                                    if (getDB().isSupportsInlineDistinct()) {
12199                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12200                                    }
12201                                    else {
12202                                            query.append(_ORDER_BY_ENTITY_TABLE);
12203                                    }
12204    
12205                                    query.append(orderByFields[i]);
12206    
12207                                    if ((i + 1) < orderByFields.length) {
12208                                            if (orderByComparator.isAscending() ^ previous) {
12209                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12210                                            }
12211                                            else {
12212                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12213                                            }
12214                                    }
12215                                    else {
12216                                            if (orderByComparator.isAscending() ^ previous) {
12217                                                    query.append(ORDER_BY_ASC);
12218                                            }
12219                                            else {
12220                                                    query.append(ORDER_BY_DESC);
12221                                            }
12222                                    }
12223                            }
12224                    }
12225                    else {
12226                            if (getDB().isSupportsInlineDistinct()) {
12227                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12228                            }
12229                            else {
12230                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12231                            }
12232                    }
12233    
12234                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12235                                    JournalArticle.class.getName(),
12236                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12237    
12238                    SQLQuery q = session.createSQLQuery(sql);
12239    
12240                    q.setFirstResult(0);
12241                    q.setMaxResults(2);
12242    
12243                    if (getDB().isSupportsInlineDistinct()) {
12244                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12245                    }
12246                    else {
12247                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12248                    }
12249    
12250                    QueryPos qPos = QueryPos.getInstance(q);
12251    
12252                    qPos.add(groupId);
12253    
12254                    if (bindStructureId) {
12255                            qPos.add(structureId);
12256                    }
12257    
12258                    if (orderByComparator != null) {
12259                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12260    
12261                            for (Object value : values) {
12262                                    qPos.add(value);
12263                            }
12264                    }
12265    
12266                    List<JournalArticle> list = q.list();
12267    
12268                    if (list.size() == 2) {
12269                            return list.get(1);
12270                    }
12271                    else {
12272                            return null;
12273                    }
12274            }
12275    
12276            /**
12277             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
12278             *
12279             * @param groupId the group ID
12280             * @param structureId the structure ID
12281             * @throws SystemException if a system exception occurred
12282             */
12283            @Override
12284            public void removeByG_S(long groupId, String structureId)
12285                    throws SystemException {
12286                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
12287                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12288                            remove(journalArticle);
12289                    }
12290            }
12291    
12292            /**
12293             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
12294             *
12295             * @param groupId the group ID
12296             * @param structureId the structure ID
12297             * @return the number of matching journal articles
12298             * @throws SystemException if a system exception occurred
12299             */
12300            @Override
12301            public int countByG_S(long groupId, String structureId)
12302                    throws SystemException {
12303                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
12304    
12305                    Object[] finderArgs = new Object[] { groupId, structureId };
12306    
12307                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12308                                    this);
12309    
12310                    if (count == null) {
12311                            StringBundler query = new StringBundler(3);
12312    
12313                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12314    
12315                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12316    
12317                            boolean bindStructureId = false;
12318    
12319                            if (structureId == null) {
12320                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12321                            }
12322                            else if (structureId.equals(StringPool.BLANK)) {
12323                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12324                            }
12325                            else {
12326                                    bindStructureId = true;
12327    
12328                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12329                            }
12330    
12331                            String sql = query.toString();
12332    
12333                            Session session = null;
12334    
12335                            try {
12336                                    session = openSession();
12337    
12338                                    Query q = session.createQuery(sql);
12339    
12340                                    QueryPos qPos = QueryPos.getInstance(q);
12341    
12342                                    qPos.add(groupId);
12343    
12344                                    if (bindStructureId) {
12345                                            qPos.add(structureId);
12346                                    }
12347    
12348                                    count = (Long)q.uniqueResult();
12349    
12350                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12351                            }
12352                            catch (Exception e) {
12353                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12354    
12355                                    throw processException(e);
12356                            }
12357                            finally {
12358                                    closeSession(session);
12359                            }
12360                    }
12361    
12362                    return count.intValue();
12363            }
12364    
12365            /**
12366             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
12367             *
12368             * @param groupId the group ID
12369             * @param structureId the structure ID
12370             * @return the number of matching journal articles that the user has permission to view
12371             * @throws SystemException if a system exception occurred
12372             */
12373            @Override
12374            public int filterCountByG_S(long groupId, String structureId)
12375                    throws SystemException {
12376                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12377                            return countByG_S(groupId, structureId);
12378                    }
12379    
12380                    StringBundler query = new StringBundler(3);
12381    
12382                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12383    
12384                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12385    
12386                    boolean bindStructureId = false;
12387    
12388                    if (structureId == null) {
12389                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12390                    }
12391                    else if (structureId.equals(StringPool.BLANK)) {
12392                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12393                    }
12394                    else {
12395                            bindStructureId = true;
12396    
12397                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12398                    }
12399    
12400                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12401                                    JournalArticle.class.getName(),
12402                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12403    
12404                    Session session = null;
12405    
12406                    try {
12407                            session = openSession();
12408    
12409                            SQLQuery q = session.createSQLQuery(sql);
12410    
12411                            q.addScalar(COUNT_COLUMN_NAME,
12412                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12413    
12414                            QueryPos qPos = QueryPos.getInstance(q);
12415    
12416                            qPos.add(groupId);
12417    
12418                            if (bindStructureId) {
12419                                    qPos.add(structureId);
12420                            }
12421    
12422                            Long count = (Long)q.uniqueResult();
12423    
12424                            return count.intValue();
12425                    }
12426                    catch (Exception e) {
12427                            throw processException(e);
12428                    }
12429                    finally {
12430                            closeSession(session);
12431                    }
12432            }
12433    
12434            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
12435            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
12436            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
12437            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
12438            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12439                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12440                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12441                            "findByG_T",
12442                            new String[] {
12443                                    Long.class.getName(), String.class.getName(),
12444                                    
12445                            Integer.class.getName(), Integer.class.getName(),
12446                                    OrderByComparator.class.getName()
12447                            });
12448            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12449                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12450                            JournalArticleImpl.class,
12451                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
12452                            new String[] { Long.class.getName(), String.class.getName() },
12453                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12454                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
12455                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12456                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12457            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12458                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12459                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
12460                            new String[] { Long.class.getName(), String.class.getName() });
12461    
12462            /**
12463             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
12464             *
12465             * @param groupId the group ID
12466             * @param templateId the template ID
12467             * @return the matching journal articles
12468             * @throws SystemException if a system exception occurred
12469             */
12470            @Override
12471            public List<JournalArticle> findByG_T(long groupId, String templateId)
12472                    throws SystemException {
12473                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
12474                            QueryUtil.ALL_POS, null);
12475            }
12476    
12477            /**
12478             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
12479             *
12480             * <p>
12481             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12482             * </p>
12483             *
12484             * @param groupId the group ID
12485             * @param templateId the template ID
12486             * @param start the lower bound of the range of journal articles
12487             * @param end the upper bound of the range of journal articles (not inclusive)
12488             * @return the range of matching journal articles
12489             * @throws SystemException if a system exception occurred
12490             */
12491            @Override
12492            public List<JournalArticle> findByG_T(long groupId, String templateId,
12493                    int start, int end) throws SystemException {
12494                    return findByG_T(groupId, templateId, start, end, null);
12495            }
12496    
12497            /**
12498             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
12499             *
12500             * <p>
12501             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12502             * </p>
12503             *
12504             * @param groupId the group ID
12505             * @param templateId the template ID
12506             * @param start the lower bound of the range of journal articles
12507             * @param end the upper bound of the range of journal articles (not inclusive)
12508             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12509             * @return the ordered range of matching journal articles
12510             * @throws SystemException if a system exception occurred
12511             */
12512            @Override
12513            public List<JournalArticle> findByG_T(long groupId, String templateId,
12514                    int start, int end, OrderByComparator orderByComparator)
12515                    throws SystemException {
12516                    boolean pagination = true;
12517                    FinderPath finderPath = null;
12518                    Object[] finderArgs = null;
12519    
12520                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12521                                    (orderByComparator == null)) {
12522                            pagination = false;
12523                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
12524                            finderArgs = new Object[] { groupId, templateId };
12525                    }
12526                    else {
12527                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
12528                            finderArgs = new Object[] {
12529                                            groupId, templateId,
12530                                            
12531                                            start, end, orderByComparator
12532                                    };
12533                    }
12534    
12535                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12536                                    finderArgs, this);
12537    
12538                    if ((list != null) && !list.isEmpty()) {
12539                            for (JournalArticle journalArticle : list) {
12540                                    if ((groupId != journalArticle.getGroupId()) ||
12541                                                    !Validator.equals(templateId,
12542                                                            journalArticle.getTemplateId())) {
12543                                            list = null;
12544    
12545                                            break;
12546                                    }
12547                            }
12548                    }
12549    
12550                    if (list == null) {
12551                            StringBundler query = null;
12552    
12553                            if (orderByComparator != null) {
12554                                    query = new StringBundler(4 +
12555                                                    (orderByComparator.getOrderByFields().length * 3));
12556                            }
12557                            else {
12558                                    query = new StringBundler(4);
12559                            }
12560    
12561                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12562    
12563                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12564    
12565                            boolean bindTemplateId = false;
12566    
12567                            if (templateId == null) {
12568                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12569                            }
12570                            else if (templateId.equals(StringPool.BLANK)) {
12571                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12572                            }
12573                            else {
12574                                    bindTemplateId = true;
12575    
12576                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12577                            }
12578    
12579                            if (orderByComparator != null) {
12580                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12581                                            orderByComparator);
12582                            }
12583                            else
12584                             if (pagination) {
12585                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12586                            }
12587    
12588                            String sql = query.toString();
12589    
12590                            Session session = null;
12591    
12592                            try {
12593                                    session = openSession();
12594    
12595                                    Query q = session.createQuery(sql);
12596    
12597                                    QueryPos qPos = QueryPos.getInstance(q);
12598    
12599                                    qPos.add(groupId);
12600    
12601                                    if (bindTemplateId) {
12602                                            qPos.add(templateId);
12603                                    }
12604    
12605                                    if (!pagination) {
12606                                            list = (List<JournalArticle>)QueryUtil.list(q,
12607                                                            getDialect(), start, end, false);
12608    
12609                                            Collections.sort(list);
12610    
12611                                            list = new UnmodifiableList<JournalArticle>(list);
12612                                    }
12613                                    else {
12614                                            list = (List<JournalArticle>)QueryUtil.list(q,
12615                                                            getDialect(), start, end);
12616                                    }
12617    
12618                                    cacheResult(list);
12619    
12620                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12621                            }
12622                            catch (Exception e) {
12623                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12624    
12625                                    throw processException(e);
12626                            }
12627                            finally {
12628                                    closeSession(session);
12629                            }
12630                    }
12631    
12632                    return list;
12633            }
12634    
12635            /**
12636             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12637             *
12638             * @param groupId the group ID
12639             * @param templateId the template ID
12640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12641             * @return the first matching journal article
12642             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12643             * @throws SystemException if a system exception occurred
12644             */
12645            @Override
12646            public JournalArticle findByG_T_First(long groupId, String templateId,
12647                    OrderByComparator orderByComparator)
12648                    throws NoSuchArticleException, SystemException {
12649                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
12650                                    orderByComparator);
12651    
12652                    if (journalArticle != null) {
12653                            return journalArticle;
12654                    }
12655    
12656                    StringBundler msg = new StringBundler(6);
12657    
12658                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12659    
12660                    msg.append("groupId=");
12661                    msg.append(groupId);
12662    
12663                    msg.append(", templateId=");
12664                    msg.append(templateId);
12665    
12666                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12667    
12668                    throw new NoSuchArticleException(msg.toString());
12669            }
12670    
12671            /**
12672             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12673             *
12674             * @param groupId the group ID
12675             * @param templateId the template ID
12676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12677             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12678             * @throws SystemException if a system exception occurred
12679             */
12680            @Override
12681            public JournalArticle fetchByG_T_First(long groupId, String templateId,
12682                    OrderByComparator orderByComparator) throws SystemException {
12683                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
12684                                    orderByComparator);
12685    
12686                    if (!list.isEmpty()) {
12687                            return list.get(0);
12688                    }
12689    
12690                    return null;
12691            }
12692    
12693            /**
12694             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12695             *
12696             * @param groupId the group ID
12697             * @param templateId the template ID
12698             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12699             * @return the last matching journal article
12700             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12701             * @throws SystemException if a system exception occurred
12702             */
12703            @Override
12704            public JournalArticle findByG_T_Last(long groupId, String templateId,
12705                    OrderByComparator orderByComparator)
12706                    throws NoSuchArticleException, SystemException {
12707                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
12708                                    orderByComparator);
12709    
12710                    if (journalArticle != null) {
12711                            return journalArticle;
12712                    }
12713    
12714                    StringBundler msg = new StringBundler(6);
12715    
12716                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12717    
12718                    msg.append("groupId=");
12719                    msg.append(groupId);
12720    
12721                    msg.append(", templateId=");
12722                    msg.append(templateId);
12723    
12724                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12725    
12726                    throw new NoSuchArticleException(msg.toString());
12727            }
12728    
12729            /**
12730             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12731             *
12732             * @param groupId the group ID
12733             * @param templateId the template ID
12734             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12735             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12736             * @throws SystemException if a system exception occurred
12737             */
12738            @Override
12739            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
12740                    OrderByComparator orderByComparator) throws SystemException {
12741                    int count = countByG_T(groupId, templateId);
12742    
12743                    if (count == 0) {
12744                            return null;
12745                    }
12746    
12747                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
12748                                    count, orderByComparator);
12749    
12750                    if (!list.isEmpty()) {
12751                            return list.get(0);
12752                    }
12753    
12754                    return null;
12755            }
12756    
12757            /**
12758             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12759             *
12760             * @param id the primary key of the current journal article
12761             * @param groupId the group ID
12762             * @param templateId the template ID
12763             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12764             * @return the previous, current, and next journal article
12765             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12766             * @throws SystemException if a system exception occurred
12767             */
12768            @Override
12769            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
12770                    String templateId, OrderByComparator orderByComparator)
12771                    throws NoSuchArticleException, SystemException {
12772                    JournalArticle journalArticle = findByPrimaryKey(id);
12773    
12774                    Session session = null;
12775    
12776                    try {
12777                            session = openSession();
12778    
12779                            JournalArticle[] array = new JournalArticleImpl[3];
12780    
12781                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12782                                            templateId, orderByComparator, true);
12783    
12784                            array[1] = journalArticle;
12785    
12786                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12787                                            templateId, orderByComparator, false);
12788    
12789                            return array;
12790                    }
12791                    catch (Exception e) {
12792                            throw processException(e);
12793                    }
12794                    finally {
12795                            closeSession(session);
12796                    }
12797            }
12798    
12799            protected JournalArticle getByG_T_PrevAndNext(Session session,
12800                    JournalArticle journalArticle, long groupId, String templateId,
12801                    OrderByComparator orderByComparator, boolean previous) {
12802                    StringBundler query = null;
12803    
12804                    if (orderByComparator != null) {
12805                            query = new StringBundler(6 +
12806                                            (orderByComparator.getOrderByFields().length * 6));
12807                    }
12808                    else {
12809                            query = new StringBundler(3);
12810                    }
12811    
12812                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12813    
12814                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12815    
12816                    boolean bindTemplateId = false;
12817    
12818                    if (templateId == null) {
12819                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12820                    }
12821                    else if (templateId.equals(StringPool.BLANK)) {
12822                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12823                    }
12824                    else {
12825                            bindTemplateId = true;
12826    
12827                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12828                    }
12829    
12830                    if (orderByComparator != null) {
12831                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12832    
12833                            if (orderByConditionFields.length > 0) {
12834                                    query.append(WHERE_AND);
12835                            }
12836    
12837                            for (int i = 0; i < orderByConditionFields.length; i++) {
12838                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12839                                    query.append(orderByConditionFields[i]);
12840    
12841                                    if ((i + 1) < orderByConditionFields.length) {
12842                                            if (orderByComparator.isAscending() ^ previous) {
12843                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12844                                            }
12845                                            else {
12846                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12847                                            }
12848                                    }
12849                                    else {
12850                                            if (orderByComparator.isAscending() ^ previous) {
12851                                                    query.append(WHERE_GREATER_THAN);
12852                                            }
12853                                            else {
12854                                                    query.append(WHERE_LESSER_THAN);
12855                                            }
12856                                    }
12857                            }
12858    
12859                            query.append(ORDER_BY_CLAUSE);
12860    
12861                            String[] orderByFields = orderByComparator.getOrderByFields();
12862    
12863                            for (int i = 0; i < orderByFields.length; i++) {
12864                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12865                                    query.append(orderByFields[i]);
12866    
12867                                    if ((i + 1) < orderByFields.length) {
12868                                            if (orderByComparator.isAscending() ^ previous) {
12869                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12870                                            }
12871                                            else {
12872                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12873                                            }
12874                                    }
12875                                    else {
12876                                            if (orderByComparator.isAscending() ^ previous) {
12877                                                    query.append(ORDER_BY_ASC);
12878                                            }
12879                                            else {
12880                                                    query.append(ORDER_BY_DESC);
12881                                            }
12882                                    }
12883                            }
12884                    }
12885                    else {
12886                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12887                    }
12888    
12889                    String sql = query.toString();
12890    
12891                    Query q = session.createQuery(sql);
12892    
12893                    q.setFirstResult(0);
12894                    q.setMaxResults(2);
12895    
12896                    QueryPos qPos = QueryPos.getInstance(q);
12897    
12898                    qPos.add(groupId);
12899    
12900                    if (bindTemplateId) {
12901                            qPos.add(templateId);
12902                    }
12903    
12904                    if (orderByComparator != null) {
12905                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12906    
12907                            for (Object value : values) {
12908                                    qPos.add(value);
12909                            }
12910                    }
12911    
12912                    List<JournalArticle> list = q.list();
12913    
12914                    if (list.size() == 2) {
12915                            return list.get(1);
12916                    }
12917                    else {
12918                            return null;
12919                    }
12920            }
12921    
12922            /**
12923             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12924             *
12925             * @param groupId the group ID
12926             * @param templateId the template ID
12927             * @return the matching journal articles that the user has permission to view
12928             * @throws SystemException if a system exception occurred
12929             */
12930            @Override
12931            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
12932                    throws SystemException {
12933                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
12934                            QueryUtil.ALL_POS, null);
12935            }
12936    
12937            /**
12938             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12939             *
12940             * <p>
12941             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12942             * </p>
12943             *
12944             * @param groupId the group ID
12945             * @param templateId the template ID
12946             * @param start the lower bound of the range of journal articles
12947             * @param end the upper bound of the range of journal articles (not inclusive)
12948             * @return the range of matching journal articles that the user has permission to view
12949             * @throws SystemException if a system exception occurred
12950             */
12951            @Override
12952            public List<JournalArticle> filterFindByG_T(long groupId,
12953                    String templateId, int start, int end) throws SystemException {
12954                    return filterFindByG_T(groupId, templateId, start, end, null);
12955            }
12956    
12957            /**
12958             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
12959             *
12960             * <p>
12961             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12962             * </p>
12963             *
12964             * @param groupId the group ID
12965             * @param templateId the template ID
12966             * @param start the lower bound of the range of journal articles
12967             * @param end the upper bound of the range of journal articles (not inclusive)
12968             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12969             * @return the ordered range of matching journal articles that the user has permission to view
12970             * @throws SystemException if a system exception occurred
12971             */
12972            @Override
12973            public List<JournalArticle> filterFindByG_T(long groupId,
12974                    String templateId, int start, int end,
12975                    OrderByComparator orderByComparator) throws SystemException {
12976                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12977                            return findByG_T(groupId, templateId, start, end, orderByComparator);
12978                    }
12979    
12980                    StringBundler query = null;
12981    
12982                    if (orderByComparator != null) {
12983                            query = new StringBundler(4 +
12984                                            (orderByComparator.getOrderByFields().length * 3));
12985                    }
12986                    else {
12987                            query = new StringBundler(4);
12988                    }
12989    
12990                    if (getDB().isSupportsInlineDistinct()) {
12991                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12992                    }
12993                    else {
12994                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12995                    }
12996    
12997                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12998    
12999                    boolean bindTemplateId = false;
13000    
13001                    if (templateId == null) {
13002                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13003                    }
13004                    else if (templateId.equals(StringPool.BLANK)) {
13005                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13006                    }
13007                    else {
13008                            bindTemplateId = true;
13009    
13010                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13011                    }
13012    
13013                    if (!getDB().isSupportsInlineDistinct()) {
13014                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13015                    }
13016    
13017                    if (orderByComparator != null) {
13018                            if (getDB().isSupportsInlineDistinct()) {
13019                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13020                                            orderByComparator, true);
13021                            }
13022                            else {
13023                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13024                                            orderByComparator, true);
13025                            }
13026                    }
13027                    else {
13028                            if (getDB().isSupportsInlineDistinct()) {
13029                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13030                            }
13031                            else {
13032                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13033                            }
13034                    }
13035    
13036                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13037                                    JournalArticle.class.getName(),
13038                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13039    
13040                    Session session = null;
13041    
13042                    try {
13043                            session = openSession();
13044    
13045                            SQLQuery q = session.createSQLQuery(sql);
13046    
13047                            if (getDB().isSupportsInlineDistinct()) {
13048                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13049                            }
13050                            else {
13051                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13052                            }
13053    
13054                            QueryPos qPos = QueryPos.getInstance(q);
13055    
13056                            qPos.add(groupId);
13057    
13058                            if (bindTemplateId) {
13059                                    qPos.add(templateId);
13060                            }
13061    
13062                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13063                                    end);
13064                    }
13065                    catch (Exception e) {
13066                            throw processException(e);
13067                    }
13068                    finally {
13069                            closeSession(session);
13070                    }
13071            }
13072    
13073            /**
13074             * 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;.
13075             *
13076             * @param id the primary key of the current journal article
13077             * @param groupId the group ID
13078             * @param templateId the template ID
13079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13080             * @return the previous, current, and next journal article
13081             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13082             * @throws SystemException if a system exception occurred
13083             */
13084            @Override
13085            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
13086                    String templateId, OrderByComparator orderByComparator)
13087                    throws NoSuchArticleException, SystemException {
13088                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13089                            return findByG_T_PrevAndNext(id, groupId, templateId,
13090                                    orderByComparator);
13091                    }
13092    
13093                    JournalArticle journalArticle = findByPrimaryKey(id);
13094    
13095                    Session session = null;
13096    
13097                    try {
13098                            session = openSession();
13099    
13100                            JournalArticle[] array = new JournalArticleImpl[3];
13101    
13102                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
13103                                            groupId, templateId, orderByComparator, true);
13104    
13105                            array[1] = journalArticle;
13106    
13107                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
13108                                            groupId, templateId, orderByComparator, false);
13109    
13110                            return array;
13111                    }
13112                    catch (Exception e) {
13113                            throw processException(e);
13114                    }
13115                    finally {
13116                            closeSession(session);
13117                    }
13118            }
13119    
13120            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
13121                    JournalArticle journalArticle, long groupId, String templateId,
13122                    OrderByComparator orderByComparator, boolean previous) {
13123                    StringBundler query = null;
13124    
13125                    if (orderByComparator != null) {
13126                            query = new StringBundler(6 +
13127                                            (orderByComparator.getOrderByFields().length * 6));
13128                    }
13129                    else {
13130                            query = new StringBundler(3);
13131                    }
13132    
13133                    if (getDB().isSupportsInlineDistinct()) {
13134                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13135                    }
13136                    else {
13137                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13138                    }
13139    
13140                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13141    
13142                    boolean bindTemplateId = false;
13143    
13144                    if (templateId == null) {
13145                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13146                    }
13147                    else if (templateId.equals(StringPool.BLANK)) {
13148                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13149                    }
13150                    else {
13151                            bindTemplateId = true;
13152    
13153                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13154                    }
13155    
13156                    if (!getDB().isSupportsInlineDistinct()) {
13157                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13158                    }
13159    
13160                    if (orderByComparator != null) {
13161                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13162    
13163                            if (orderByConditionFields.length > 0) {
13164                                    query.append(WHERE_AND);
13165                            }
13166    
13167                            for (int i = 0; i < orderByConditionFields.length; i++) {
13168                                    if (getDB().isSupportsInlineDistinct()) {
13169                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13170                                    }
13171                                    else {
13172                                            query.append(_ORDER_BY_ENTITY_TABLE);
13173                                    }
13174    
13175                                    query.append(orderByConditionFields[i]);
13176    
13177                                    if ((i + 1) < orderByConditionFields.length) {
13178                                            if (orderByComparator.isAscending() ^ previous) {
13179                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13180                                            }
13181                                            else {
13182                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13183                                            }
13184                                    }
13185                                    else {
13186                                            if (orderByComparator.isAscending() ^ previous) {
13187                                                    query.append(WHERE_GREATER_THAN);
13188                                            }
13189                                            else {
13190                                                    query.append(WHERE_LESSER_THAN);
13191                                            }
13192                                    }
13193                            }
13194    
13195                            query.append(ORDER_BY_CLAUSE);
13196    
13197                            String[] orderByFields = orderByComparator.getOrderByFields();
13198    
13199                            for (int i = 0; i < orderByFields.length; i++) {
13200                                    if (getDB().isSupportsInlineDistinct()) {
13201                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13202                                    }
13203                                    else {
13204                                            query.append(_ORDER_BY_ENTITY_TABLE);
13205                                    }
13206    
13207                                    query.append(orderByFields[i]);
13208    
13209                                    if ((i + 1) < orderByFields.length) {
13210                                            if (orderByComparator.isAscending() ^ previous) {
13211                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13212                                            }
13213                                            else {
13214                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13215                                            }
13216                                    }
13217                                    else {
13218                                            if (orderByComparator.isAscending() ^ previous) {
13219                                                    query.append(ORDER_BY_ASC);
13220                                            }
13221                                            else {
13222                                                    query.append(ORDER_BY_DESC);
13223                                            }
13224                                    }
13225                            }
13226                    }
13227                    else {
13228                            if (getDB().isSupportsInlineDistinct()) {
13229                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13230                            }
13231                            else {
13232                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13233                            }
13234                    }
13235    
13236                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13237                                    JournalArticle.class.getName(),
13238                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13239    
13240                    SQLQuery q = session.createSQLQuery(sql);
13241    
13242                    q.setFirstResult(0);
13243                    q.setMaxResults(2);
13244    
13245                    if (getDB().isSupportsInlineDistinct()) {
13246                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13247                    }
13248                    else {
13249                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13250                    }
13251    
13252                    QueryPos qPos = QueryPos.getInstance(q);
13253    
13254                    qPos.add(groupId);
13255    
13256                    if (bindTemplateId) {
13257                            qPos.add(templateId);
13258                    }
13259    
13260                    if (orderByComparator != null) {
13261                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13262    
13263                            for (Object value : values) {
13264                                    qPos.add(value);
13265                            }
13266                    }
13267    
13268                    List<JournalArticle> list = q.list();
13269    
13270                    if (list.size() == 2) {
13271                            return list.get(1);
13272                    }
13273                    else {
13274                            return null;
13275                    }
13276            }
13277    
13278            /**
13279             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
13280             *
13281             * @param groupId the group ID
13282             * @param templateId the template ID
13283             * @throws SystemException if a system exception occurred
13284             */
13285            @Override
13286            public void removeByG_T(long groupId, String templateId)
13287                    throws SystemException {
13288                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
13289                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13290                            remove(journalArticle);
13291                    }
13292            }
13293    
13294            /**
13295             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
13296             *
13297             * @param groupId the group ID
13298             * @param templateId the template ID
13299             * @return the number of matching journal articles
13300             * @throws SystemException if a system exception occurred
13301             */
13302            @Override
13303            public int countByG_T(long groupId, String templateId)
13304                    throws SystemException {
13305                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
13306    
13307                    Object[] finderArgs = new Object[] { groupId, templateId };
13308    
13309                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13310                                    this);
13311    
13312                    if (count == null) {
13313                            StringBundler query = new StringBundler(3);
13314    
13315                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13316    
13317                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13318    
13319                            boolean bindTemplateId = false;
13320    
13321                            if (templateId == null) {
13322                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13323                            }
13324                            else if (templateId.equals(StringPool.BLANK)) {
13325                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13326                            }
13327                            else {
13328                                    bindTemplateId = true;
13329    
13330                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13331                            }
13332    
13333                            String sql = query.toString();
13334    
13335                            Session session = null;
13336    
13337                            try {
13338                                    session = openSession();
13339    
13340                                    Query q = session.createQuery(sql);
13341    
13342                                    QueryPos qPos = QueryPos.getInstance(q);
13343    
13344                                    qPos.add(groupId);
13345    
13346                                    if (bindTemplateId) {
13347                                            qPos.add(templateId);
13348                                    }
13349    
13350                                    count = (Long)q.uniqueResult();
13351    
13352                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13353                            }
13354                            catch (Exception e) {
13355                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13356    
13357                                    throw processException(e);
13358                            }
13359                            finally {
13360                                    closeSession(session);
13361                            }
13362                    }
13363    
13364                    return count.intValue();
13365            }
13366    
13367            /**
13368             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
13369             *
13370             * @param groupId the group ID
13371             * @param templateId the template ID
13372             * @return the number of matching journal articles that the user has permission to view
13373             * @throws SystemException if a system exception occurred
13374             */
13375            @Override
13376            public int filterCountByG_T(long groupId, String templateId)
13377                    throws SystemException {
13378                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13379                            return countByG_T(groupId, templateId);
13380                    }
13381    
13382                    StringBundler query = new StringBundler(3);
13383    
13384                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13385    
13386                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13387    
13388                    boolean bindTemplateId = false;
13389    
13390                    if (templateId == null) {
13391                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13392                    }
13393                    else if (templateId.equals(StringPool.BLANK)) {
13394                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13395                    }
13396                    else {
13397                            bindTemplateId = true;
13398    
13399                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13400                    }
13401    
13402                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13403                                    JournalArticle.class.getName(),
13404                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13405    
13406                    Session session = null;
13407    
13408                    try {
13409                            session = openSession();
13410    
13411                            SQLQuery q = session.createSQLQuery(sql);
13412    
13413                            q.addScalar(COUNT_COLUMN_NAME,
13414                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13415    
13416                            QueryPos qPos = QueryPos.getInstance(q);
13417    
13418                            qPos.add(groupId);
13419    
13420                            if (bindTemplateId) {
13421                                    qPos.add(templateId);
13422                            }
13423    
13424                            Long count = (Long)q.uniqueResult();
13425    
13426                            return count.intValue();
13427                    }
13428                    catch (Exception e) {
13429                            throw processException(e);
13430                    }
13431                    finally {
13432                            closeSession(session);
13433                    }
13434            }
13435    
13436            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
13437            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
13438            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
13439            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
13440            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13441                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13442                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13443                            "findByG_L",
13444                            new String[] {
13445                                    Long.class.getName(), String.class.getName(),
13446                                    
13447                            Integer.class.getName(), Integer.class.getName(),
13448                                    OrderByComparator.class.getName()
13449                            });
13450            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13451                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13452                            JournalArticleImpl.class,
13453                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
13454                            new String[] { Long.class.getName(), String.class.getName() },
13455                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13456                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
13457                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13458                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13459            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13460                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13461                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
13462                            new String[] { Long.class.getName(), String.class.getName() });
13463    
13464            /**
13465             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13466             *
13467             * @param groupId the group ID
13468             * @param layoutUuid the layout uuid
13469             * @return the matching journal articles
13470             * @throws SystemException if a system exception occurred
13471             */
13472            @Override
13473            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
13474                    throws SystemException {
13475                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13476                            QueryUtil.ALL_POS, null);
13477            }
13478    
13479            /**
13480             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13481             *
13482             * <p>
13483             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13484             * </p>
13485             *
13486             * @param groupId the group ID
13487             * @param layoutUuid the layout uuid
13488             * @param start the lower bound of the range of journal articles
13489             * @param end the upper bound of the range of journal articles (not inclusive)
13490             * @return the range of matching journal articles
13491             * @throws SystemException if a system exception occurred
13492             */
13493            @Override
13494            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13495                    int start, int end) throws SystemException {
13496                    return findByG_L(groupId, layoutUuid, start, end, null);
13497            }
13498    
13499            /**
13500             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13501             *
13502             * <p>
13503             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13504             * </p>
13505             *
13506             * @param groupId the group ID
13507             * @param layoutUuid the layout uuid
13508             * @param start the lower bound of the range of journal articles
13509             * @param end the upper bound of the range of journal articles (not inclusive)
13510             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13511             * @return the ordered range of matching journal articles
13512             * @throws SystemException if a system exception occurred
13513             */
13514            @Override
13515            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13516                    int start, int end, OrderByComparator orderByComparator)
13517                    throws SystemException {
13518                    boolean pagination = true;
13519                    FinderPath finderPath = null;
13520                    Object[] finderArgs = null;
13521    
13522                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13523                                    (orderByComparator == null)) {
13524                            pagination = false;
13525                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
13526                            finderArgs = new Object[] { groupId, layoutUuid };
13527                    }
13528                    else {
13529                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
13530                            finderArgs = new Object[] {
13531                                            groupId, layoutUuid,
13532                                            
13533                                            start, end, orderByComparator
13534                                    };
13535                    }
13536    
13537                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13538                                    finderArgs, this);
13539    
13540                    if ((list != null) && !list.isEmpty()) {
13541                            for (JournalArticle journalArticle : list) {
13542                                    if ((groupId != journalArticle.getGroupId()) ||
13543                                                    !Validator.equals(layoutUuid,
13544                                                            journalArticle.getLayoutUuid())) {
13545                                            list = null;
13546    
13547                                            break;
13548                                    }
13549                            }
13550                    }
13551    
13552                    if (list == null) {
13553                            StringBundler query = null;
13554    
13555                            if (orderByComparator != null) {
13556                                    query = new StringBundler(4 +
13557                                                    (orderByComparator.getOrderByFields().length * 3));
13558                            }
13559                            else {
13560                                    query = new StringBundler(4);
13561                            }
13562    
13563                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13564    
13565                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13566    
13567                            boolean bindLayoutUuid = false;
13568    
13569                            if (layoutUuid == null) {
13570                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13571                            }
13572                            else if (layoutUuid.equals(StringPool.BLANK)) {
13573                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13574                            }
13575                            else {
13576                                    bindLayoutUuid = true;
13577    
13578                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13579                            }
13580    
13581                            if (orderByComparator != null) {
13582                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13583                                            orderByComparator);
13584                            }
13585                            else
13586                             if (pagination) {
13587                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13588                            }
13589    
13590                            String sql = query.toString();
13591    
13592                            Session session = null;
13593    
13594                            try {
13595                                    session = openSession();
13596    
13597                                    Query q = session.createQuery(sql);
13598    
13599                                    QueryPos qPos = QueryPos.getInstance(q);
13600    
13601                                    qPos.add(groupId);
13602    
13603                                    if (bindLayoutUuid) {
13604                                            qPos.add(layoutUuid);
13605                                    }
13606    
13607                                    if (!pagination) {
13608                                            list = (List<JournalArticle>)QueryUtil.list(q,
13609                                                            getDialect(), start, end, false);
13610    
13611                                            Collections.sort(list);
13612    
13613                                            list = new UnmodifiableList<JournalArticle>(list);
13614                                    }
13615                                    else {
13616                                            list = (List<JournalArticle>)QueryUtil.list(q,
13617                                                            getDialect(), start, end);
13618                                    }
13619    
13620                                    cacheResult(list);
13621    
13622                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13623                            }
13624                            catch (Exception e) {
13625                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13626    
13627                                    throw processException(e);
13628                            }
13629                            finally {
13630                                    closeSession(session);
13631                            }
13632                    }
13633    
13634                    return list;
13635            }
13636    
13637            /**
13638             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13639             *
13640             * @param groupId the group ID
13641             * @param layoutUuid the layout uuid
13642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13643             * @return the first matching journal article
13644             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13645             * @throws SystemException if a system exception occurred
13646             */
13647            @Override
13648            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
13649                    OrderByComparator orderByComparator)
13650                    throws NoSuchArticleException, SystemException {
13651                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
13652                                    orderByComparator);
13653    
13654                    if (journalArticle != null) {
13655                            return journalArticle;
13656                    }
13657    
13658                    StringBundler msg = new StringBundler(6);
13659    
13660                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13661    
13662                    msg.append("groupId=");
13663                    msg.append(groupId);
13664    
13665                    msg.append(", layoutUuid=");
13666                    msg.append(layoutUuid);
13667    
13668                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13669    
13670                    throw new NoSuchArticleException(msg.toString());
13671            }
13672    
13673            /**
13674             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13675             *
13676             * @param groupId the group ID
13677             * @param layoutUuid the layout uuid
13678             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13679             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13680             * @throws SystemException if a system exception occurred
13681             */
13682            @Override
13683            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
13684                    OrderByComparator orderByComparator) throws SystemException {
13685                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
13686                                    orderByComparator);
13687    
13688                    if (!list.isEmpty()) {
13689                            return list.get(0);
13690                    }
13691    
13692                    return null;
13693            }
13694    
13695            /**
13696             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13697             *
13698             * @param groupId the group ID
13699             * @param layoutUuid the layout uuid
13700             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13701             * @return the last matching journal article
13702             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13703             * @throws SystemException if a system exception occurred
13704             */
13705            @Override
13706            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
13707                    OrderByComparator orderByComparator)
13708                    throws NoSuchArticleException, SystemException {
13709                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
13710                                    orderByComparator);
13711    
13712                    if (journalArticle != null) {
13713                            return journalArticle;
13714                    }
13715    
13716                    StringBundler msg = new StringBundler(6);
13717    
13718                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13719    
13720                    msg.append("groupId=");
13721                    msg.append(groupId);
13722    
13723                    msg.append(", layoutUuid=");
13724                    msg.append(layoutUuid);
13725    
13726                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13727    
13728                    throw new NoSuchArticleException(msg.toString());
13729            }
13730    
13731            /**
13732             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13733             *
13734             * @param groupId the group ID
13735             * @param layoutUuid the layout uuid
13736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13737             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13738             * @throws SystemException if a system exception occurred
13739             */
13740            @Override
13741            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
13742                    OrderByComparator orderByComparator) throws SystemException {
13743                    int count = countByG_L(groupId, layoutUuid);
13744    
13745                    if (count == 0) {
13746                            return null;
13747                    }
13748    
13749                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
13750                                    count, orderByComparator);
13751    
13752                    if (!list.isEmpty()) {
13753                            return list.get(0);
13754                    }
13755    
13756                    return null;
13757            }
13758    
13759            /**
13760             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13761             *
13762             * @param id the primary key of the current journal article
13763             * @param groupId the group ID
13764             * @param layoutUuid the layout uuid
13765             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13766             * @return the previous, current, and next journal article
13767             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13768             * @throws SystemException if a system exception occurred
13769             */
13770            @Override
13771            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
13772                    String layoutUuid, OrderByComparator orderByComparator)
13773                    throws NoSuchArticleException, SystemException {
13774                    JournalArticle journalArticle = findByPrimaryKey(id);
13775    
13776                    Session session = null;
13777    
13778                    try {
13779                            session = openSession();
13780    
13781                            JournalArticle[] array = new JournalArticleImpl[3];
13782    
13783                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13784                                            layoutUuid, orderByComparator, true);
13785    
13786                            array[1] = journalArticle;
13787    
13788                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13789                                            layoutUuid, orderByComparator, false);
13790    
13791                            return array;
13792                    }
13793                    catch (Exception e) {
13794                            throw processException(e);
13795                    }
13796                    finally {
13797                            closeSession(session);
13798                    }
13799            }
13800    
13801            protected JournalArticle getByG_L_PrevAndNext(Session session,
13802                    JournalArticle journalArticle, long groupId, String layoutUuid,
13803                    OrderByComparator orderByComparator, boolean previous) {
13804                    StringBundler query = null;
13805    
13806                    if (orderByComparator != null) {
13807                            query = new StringBundler(6 +
13808                                            (orderByComparator.getOrderByFields().length * 6));
13809                    }
13810                    else {
13811                            query = new StringBundler(3);
13812                    }
13813    
13814                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13815    
13816                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13817    
13818                    boolean bindLayoutUuid = false;
13819    
13820                    if (layoutUuid == null) {
13821                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13822                    }
13823                    else if (layoutUuid.equals(StringPool.BLANK)) {
13824                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13825                    }
13826                    else {
13827                            bindLayoutUuid = true;
13828    
13829                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13830                    }
13831    
13832                    if (orderByComparator != null) {
13833                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13834    
13835                            if (orderByConditionFields.length > 0) {
13836                                    query.append(WHERE_AND);
13837                            }
13838    
13839                            for (int i = 0; i < orderByConditionFields.length; i++) {
13840                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13841                                    query.append(orderByConditionFields[i]);
13842    
13843                                    if ((i + 1) < orderByConditionFields.length) {
13844                                            if (orderByComparator.isAscending() ^ previous) {
13845                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13846                                            }
13847                                            else {
13848                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13849                                            }
13850                                    }
13851                                    else {
13852                                            if (orderByComparator.isAscending() ^ previous) {
13853                                                    query.append(WHERE_GREATER_THAN);
13854                                            }
13855                                            else {
13856                                                    query.append(WHERE_LESSER_THAN);
13857                                            }
13858                                    }
13859                            }
13860    
13861                            query.append(ORDER_BY_CLAUSE);
13862    
13863                            String[] orderByFields = orderByComparator.getOrderByFields();
13864    
13865                            for (int i = 0; i < orderByFields.length; i++) {
13866                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13867                                    query.append(orderByFields[i]);
13868    
13869                                    if ((i + 1) < orderByFields.length) {
13870                                            if (orderByComparator.isAscending() ^ previous) {
13871                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13872                                            }
13873                                            else {
13874                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13875                                            }
13876                                    }
13877                                    else {
13878                                            if (orderByComparator.isAscending() ^ previous) {
13879                                                    query.append(ORDER_BY_ASC);
13880                                            }
13881                                            else {
13882                                                    query.append(ORDER_BY_DESC);
13883                                            }
13884                                    }
13885                            }
13886                    }
13887                    else {
13888                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13889                    }
13890    
13891                    String sql = query.toString();
13892    
13893                    Query q = session.createQuery(sql);
13894    
13895                    q.setFirstResult(0);
13896                    q.setMaxResults(2);
13897    
13898                    QueryPos qPos = QueryPos.getInstance(q);
13899    
13900                    qPos.add(groupId);
13901    
13902                    if (bindLayoutUuid) {
13903                            qPos.add(layoutUuid);
13904                    }
13905    
13906                    if (orderByComparator != null) {
13907                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13908    
13909                            for (Object value : values) {
13910                                    qPos.add(value);
13911                            }
13912                    }
13913    
13914                    List<JournalArticle> list = q.list();
13915    
13916                    if (list.size() == 2) {
13917                            return list.get(1);
13918                    }
13919                    else {
13920                            return null;
13921                    }
13922            }
13923    
13924            /**
13925             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13926             *
13927             * @param groupId the group ID
13928             * @param layoutUuid the layout uuid
13929             * @return the matching journal articles that the user has permission to view
13930             * @throws SystemException if a system exception occurred
13931             */
13932            @Override
13933            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
13934                    throws SystemException {
13935                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13936                            QueryUtil.ALL_POS, null);
13937            }
13938    
13939            /**
13940             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13941             *
13942             * <p>
13943             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13944             * </p>
13945             *
13946             * @param groupId the group ID
13947             * @param layoutUuid the layout uuid
13948             * @param start the lower bound of the range of journal articles
13949             * @param end the upper bound of the range of journal articles (not inclusive)
13950             * @return the range of matching journal articles that the user has permission to view
13951             * @throws SystemException if a system exception occurred
13952             */
13953            @Override
13954            public List<JournalArticle> filterFindByG_L(long groupId,
13955                    String layoutUuid, int start, int end) throws SystemException {
13956                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
13957            }
13958    
13959            /**
13960             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
13961             *
13962             * <p>
13963             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13964             * </p>
13965             *
13966             * @param groupId the group ID
13967             * @param layoutUuid the layout uuid
13968             * @param start the lower bound of the range of journal articles
13969             * @param end the upper bound of the range of journal articles (not inclusive)
13970             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13971             * @return the ordered range of matching journal articles that the user has permission to view
13972             * @throws SystemException if a system exception occurred
13973             */
13974            @Override
13975            public List<JournalArticle> filterFindByG_L(long groupId,
13976                    String layoutUuid, int start, int end,
13977                    OrderByComparator orderByComparator) throws SystemException {
13978                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13979                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
13980                    }
13981    
13982                    StringBundler query = null;
13983    
13984                    if (orderByComparator != null) {
13985                            query = new StringBundler(4 +
13986                                            (orderByComparator.getOrderByFields().length * 3));
13987                    }
13988                    else {
13989                            query = new StringBundler(4);
13990                    }
13991    
13992                    if (getDB().isSupportsInlineDistinct()) {
13993                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13994                    }
13995                    else {
13996                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13997                    }
13998    
13999                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14000    
14001                    boolean bindLayoutUuid = false;
14002    
14003                    if (layoutUuid == null) {
14004                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14005                    }
14006                    else if (layoutUuid.equals(StringPool.BLANK)) {
14007                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14008                    }
14009                    else {
14010                            bindLayoutUuid = true;
14011    
14012                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14013                    }
14014    
14015                    if (!getDB().isSupportsInlineDistinct()) {
14016                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14017                    }
14018    
14019                    if (orderByComparator != null) {
14020                            if (getDB().isSupportsInlineDistinct()) {
14021                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14022                                            orderByComparator, true);
14023                            }
14024                            else {
14025                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14026                                            orderByComparator, true);
14027                            }
14028                    }
14029                    else {
14030                            if (getDB().isSupportsInlineDistinct()) {
14031                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14032                            }
14033                            else {
14034                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14035                            }
14036                    }
14037    
14038                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14039                                    JournalArticle.class.getName(),
14040                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14041    
14042                    Session session = null;
14043    
14044                    try {
14045                            session = openSession();
14046    
14047                            SQLQuery q = session.createSQLQuery(sql);
14048    
14049                            if (getDB().isSupportsInlineDistinct()) {
14050                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14051                            }
14052                            else {
14053                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14054                            }
14055    
14056                            QueryPos qPos = QueryPos.getInstance(q);
14057    
14058                            qPos.add(groupId);
14059    
14060                            if (bindLayoutUuid) {
14061                                    qPos.add(layoutUuid);
14062                            }
14063    
14064                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14065                                    end);
14066                    }
14067                    catch (Exception e) {
14068                            throw processException(e);
14069                    }
14070                    finally {
14071                            closeSession(session);
14072                    }
14073            }
14074    
14075            /**
14076             * 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;.
14077             *
14078             * @param id the primary key of the current journal article
14079             * @param groupId the group ID
14080             * @param layoutUuid the layout uuid
14081             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14082             * @return the previous, current, and next journal article
14083             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14084             * @throws SystemException if a system exception occurred
14085             */
14086            @Override
14087            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
14088                    String layoutUuid, OrderByComparator orderByComparator)
14089                    throws NoSuchArticleException, SystemException {
14090                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14091                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
14092                                    orderByComparator);
14093                    }
14094    
14095                    JournalArticle journalArticle = findByPrimaryKey(id);
14096    
14097                    Session session = null;
14098    
14099                    try {
14100                            session = openSession();
14101    
14102                            JournalArticle[] array = new JournalArticleImpl[3];
14103    
14104                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
14105                                            groupId, layoutUuid, orderByComparator, true);
14106    
14107                            array[1] = journalArticle;
14108    
14109                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
14110                                            groupId, layoutUuid, orderByComparator, false);
14111    
14112                            return array;
14113                    }
14114                    catch (Exception e) {
14115                            throw processException(e);
14116                    }
14117                    finally {
14118                            closeSession(session);
14119                    }
14120            }
14121    
14122            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
14123                    JournalArticle journalArticle, long groupId, String layoutUuid,
14124                    OrderByComparator orderByComparator, boolean previous) {
14125                    StringBundler query = null;
14126    
14127                    if (orderByComparator != null) {
14128                            query = new StringBundler(6 +
14129                                            (orderByComparator.getOrderByFields().length * 6));
14130                    }
14131                    else {
14132                            query = new StringBundler(3);
14133                    }
14134    
14135                    if (getDB().isSupportsInlineDistinct()) {
14136                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14137                    }
14138                    else {
14139                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14140                    }
14141    
14142                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14143    
14144                    boolean bindLayoutUuid = false;
14145    
14146                    if (layoutUuid == null) {
14147                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14148                    }
14149                    else if (layoutUuid.equals(StringPool.BLANK)) {
14150                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14151                    }
14152                    else {
14153                            bindLayoutUuid = true;
14154    
14155                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14156                    }
14157    
14158                    if (!getDB().isSupportsInlineDistinct()) {
14159                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14160                    }
14161    
14162                    if (orderByComparator != null) {
14163                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14164    
14165                            if (orderByConditionFields.length > 0) {
14166                                    query.append(WHERE_AND);
14167                            }
14168    
14169                            for (int i = 0; i < orderByConditionFields.length; i++) {
14170                                    if (getDB().isSupportsInlineDistinct()) {
14171                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14172                                    }
14173                                    else {
14174                                            query.append(_ORDER_BY_ENTITY_TABLE);
14175                                    }
14176    
14177                                    query.append(orderByConditionFields[i]);
14178    
14179                                    if ((i + 1) < orderByConditionFields.length) {
14180                                            if (orderByComparator.isAscending() ^ previous) {
14181                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14182                                            }
14183                                            else {
14184                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14185                                            }
14186                                    }
14187                                    else {
14188                                            if (orderByComparator.isAscending() ^ previous) {
14189                                                    query.append(WHERE_GREATER_THAN);
14190                                            }
14191                                            else {
14192                                                    query.append(WHERE_LESSER_THAN);
14193                                            }
14194                                    }
14195                            }
14196    
14197                            query.append(ORDER_BY_CLAUSE);
14198    
14199                            String[] orderByFields = orderByComparator.getOrderByFields();
14200    
14201                            for (int i = 0; i < orderByFields.length; i++) {
14202                                    if (getDB().isSupportsInlineDistinct()) {
14203                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14204                                    }
14205                                    else {
14206                                            query.append(_ORDER_BY_ENTITY_TABLE);
14207                                    }
14208    
14209                                    query.append(orderByFields[i]);
14210    
14211                                    if ((i + 1) < orderByFields.length) {
14212                                            if (orderByComparator.isAscending() ^ previous) {
14213                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14214                                            }
14215                                            else {
14216                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14217                                            }
14218                                    }
14219                                    else {
14220                                            if (orderByComparator.isAscending() ^ previous) {
14221                                                    query.append(ORDER_BY_ASC);
14222                                            }
14223                                            else {
14224                                                    query.append(ORDER_BY_DESC);
14225                                            }
14226                                    }
14227                            }
14228                    }
14229                    else {
14230                            if (getDB().isSupportsInlineDistinct()) {
14231                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14232                            }
14233                            else {
14234                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14235                            }
14236                    }
14237    
14238                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14239                                    JournalArticle.class.getName(),
14240                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14241    
14242                    SQLQuery q = session.createSQLQuery(sql);
14243    
14244                    q.setFirstResult(0);
14245                    q.setMaxResults(2);
14246    
14247                    if (getDB().isSupportsInlineDistinct()) {
14248                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14249                    }
14250                    else {
14251                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14252                    }
14253    
14254                    QueryPos qPos = QueryPos.getInstance(q);
14255    
14256                    qPos.add(groupId);
14257    
14258                    if (bindLayoutUuid) {
14259                            qPos.add(layoutUuid);
14260                    }
14261    
14262                    if (orderByComparator != null) {
14263                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14264    
14265                            for (Object value : values) {
14266                                    qPos.add(value);
14267                            }
14268                    }
14269    
14270                    List<JournalArticle> list = q.list();
14271    
14272                    if (list.size() == 2) {
14273                            return list.get(1);
14274                    }
14275                    else {
14276                            return null;
14277                    }
14278            }
14279    
14280            /**
14281             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
14282             *
14283             * @param groupId the group ID
14284             * @param layoutUuid the layout uuid
14285             * @throws SystemException if a system exception occurred
14286             */
14287            @Override
14288            public void removeByG_L(long groupId, String layoutUuid)
14289                    throws SystemException {
14290                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
14291                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14292                            remove(journalArticle);
14293                    }
14294            }
14295    
14296            /**
14297             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
14298             *
14299             * @param groupId the group ID
14300             * @param layoutUuid the layout uuid
14301             * @return the number of matching journal articles
14302             * @throws SystemException if a system exception occurred
14303             */
14304            @Override
14305            public int countByG_L(long groupId, String layoutUuid)
14306                    throws SystemException {
14307                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
14308    
14309                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
14310    
14311                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14312                                    this);
14313    
14314                    if (count == null) {
14315                            StringBundler query = new StringBundler(3);
14316    
14317                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14318    
14319                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14320    
14321                            boolean bindLayoutUuid = false;
14322    
14323                            if (layoutUuid == null) {
14324                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14325                            }
14326                            else if (layoutUuid.equals(StringPool.BLANK)) {
14327                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14328                            }
14329                            else {
14330                                    bindLayoutUuid = true;
14331    
14332                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14333                            }
14334    
14335                            String sql = query.toString();
14336    
14337                            Session session = null;
14338    
14339                            try {
14340                                    session = openSession();
14341    
14342                                    Query q = session.createQuery(sql);
14343    
14344                                    QueryPos qPos = QueryPos.getInstance(q);
14345    
14346                                    qPos.add(groupId);
14347    
14348                                    if (bindLayoutUuid) {
14349                                            qPos.add(layoutUuid);
14350                                    }
14351    
14352                                    count = (Long)q.uniqueResult();
14353    
14354                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14355                            }
14356                            catch (Exception e) {
14357                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14358    
14359                                    throw processException(e);
14360                            }
14361                            finally {
14362                                    closeSession(session);
14363                            }
14364                    }
14365    
14366                    return count.intValue();
14367            }
14368    
14369            /**
14370             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
14371             *
14372             * @param groupId the group ID
14373             * @param layoutUuid the layout uuid
14374             * @return the number of matching journal articles that the user has permission to view
14375             * @throws SystemException if a system exception occurred
14376             */
14377            @Override
14378            public int filterCountByG_L(long groupId, String layoutUuid)
14379                    throws SystemException {
14380                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14381                            return countByG_L(groupId, layoutUuid);
14382                    }
14383    
14384                    StringBundler query = new StringBundler(3);
14385    
14386                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14387    
14388                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14389    
14390                    boolean bindLayoutUuid = false;
14391    
14392                    if (layoutUuid == null) {
14393                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14394                    }
14395                    else if (layoutUuid.equals(StringPool.BLANK)) {
14396                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14397                    }
14398                    else {
14399                            bindLayoutUuid = true;
14400    
14401                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14402                    }
14403    
14404                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14405                                    JournalArticle.class.getName(),
14406                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14407    
14408                    Session session = null;
14409    
14410                    try {
14411                            session = openSession();
14412    
14413                            SQLQuery q = session.createSQLQuery(sql);
14414    
14415                            q.addScalar(COUNT_COLUMN_NAME,
14416                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14417    
14418                            QueryPos qPos = QueryPos.getInstance(q);
14419    
14420                            qPos.add(groupId);
14421    
14422                            if (bindLayoutUuid) {
14423                                    qPos.add(layoutUuid);
14424                            }
14425    
14426                            Long count = (Long)q.uniqueResult();
14427    
14428                            return count.intValue();
14429                    }
14430                    catch (Exception e) {
14431                            throw processException(e);
14432                    }
14433                    finally {
14434                            closeSession(session);
14435                    }
14436            }
14437    
14438            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
14439            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
14440            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
14441            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
14442            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14443                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14444                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14445                            "findByG_ST",
14446                            new String[] {
14447                                    Long.class.getName(), Integer.class.getName(),
14448                                    
14449                            Integer.class.getName(), Integer.class.getName(),
14450                                    OrderByComparator.class.getName()
14451                            });
14452            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14453                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14454                            JournalArticleImpl.class,
14455                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
14456                            new String[] { Long.class.getName(), Integer.class.getName() },
14457                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
14458                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14459                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14460                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14461            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14462                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14463                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
14464                            new String[] { Long.class.getName(), Integer.class.getName() });
14465    
14466            /**
14467             * Returns all the journal articles where groupId = &#63; and status = &#63;.
14468             *
14469             * @param groupId the group ID
14470             * @param status the status
14471             * @return the matching journal articles
14472             * @throws SystemException if a system exception occurred
14473             */
14474            @Override
14475            public List<JournalArticle> findByG_ST(long groupId, int status)
14476                    throws SystemException {
14477                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
14478                            QueryUtil.ALL_POS, null);
14479            }
14480    
14481            /**
14482             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
14483             *
14484             * <p>
14485             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14486             * </p>
14487             *
14488             * @param groupId the group ID
14489             * @param status the status
14490             * @param start the lower bound of the range of journal articles
14491             * @param end the upper bound of the range of journal articles (not inclusive)
14492             * @return the range of matching journal articles
14493             * @throws SystemException if a system exception occurred
14494             */
14495            @Override
14496            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14497                    int end) throws SystemException {
14498                    return findByG_ST(groupId, status, start, end, null);
14499            }
14500    
14501            /**
14502             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
14503             *
14504             * <p>
14505             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14506             * </p>
14507             *
14508             * @param groupId the group ID
14509             * @param status the status
14510             * @param start the lower bound of the range of journal articles
14511             * @param end the upper bound of the range of journal articles (not inclusive)
14512             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14513             * @return the ordered range of matching journal articles
14514             * @throws SystemException if a system exception occurred
14515             */
14516            @Override
14517            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14518                    int end, OrderByComparator orderByComparator) throws SystemException {
14519                    boolean pagination = true;
14520                    FinderPath finderPath = null;
14521                    Object[] finderArgs = null;
14522    
14523                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14524                                    (orderByComparator == null)) {
14525                            pagination = false;
14526                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
14527                            finderArgs = new Object[] { groupId, status };
14528                    }
14529                    else {
14530                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
14531                            finderArgs = new Object[] {
14532                                            groupId, status,
14533                                            
14534                                            start, end, orderByComparator
14535                                    };
14536                    }
14537    
14538                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14539                                    finderArgs, this);
14540    
14541                    if ((list != null) && !list.isEmpty()) {
14542                            for (JournalArticle journalArticle : list) {
14543                                    if ((groupId != journalArticle.getGroupId()) ||
14544                                                    (status != journalArticle.getStatus())) {
14545                                            list = null;
14546    
14547                                            break;
14548                                    }
14549                            }
14550                    }
14551    
14552                    if (list == null) {
14553                            StringBundler query = null;
14554    
14555                            if (orderByComparator != null) {
14556                                    query = new StringBundler(4 +
14557                                                    (orderByComparator.getOrderByFields().length * 3));
14558                            }
14559                            else {
14560                                    query = new StringBundler(4);
14561                            }
14562    
14563                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14564    
14565                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14566    
14567                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14568    
14569                            if (orderByComparator != null) {
14570                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14571                                            orderByComparator);
14572                            }
14573                            else
14574                             if (pagination) {
14575                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14576                            }
14577    
14578                            String sql = query.toString();
14579    
14580                            Session session = null;
14581    
14582                            try {
14583                                    session = openSession();
14584    
14585                                    Query q = session.createQuery(sql);
14586    
14587                                    QueryPos qPos = QueryPos.getInstance(q);
14588    
14589                                    qPos.add(groupId);
14590    
14591                                    qPos.add(status);
14592    
14593                                    if (!pagination) {
14594                                            list = (List<JournalArticle>)QueryUtil.list(q,
14595                                                            getDialect(), start, end, false);
14596    
14597                                            Collections.sort(list);
14598    
14599                                            list = new UnmodifiableList<JournalArticle>(list);
14600                                    }
14601                                    else {
14602                                            list = (List<JournalArticle>)QueryUtil.list(q,
14603                                                            getDialect(), start, end);
14604                                    }
14605    
14606                                    cacheResult(list);
14607    
14608                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14609                            }
14610                            catch (Exception e) {
14611                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14612    
14613                                    throw processException(e);
14614                            }
14615                            finally {
14616                                    closeSession(session);
14617                            }
14618                    }
14619    
14620                    return list;
14621            }
14622    
14623            /**
14624             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14625             *
14626             * @param groupId the group ID
14627             * @param status the status
14628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14629             * @return the first matching journal article
14630             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14631             * @throws SystemException if a system exception occurred
14632             */
14633            @Override
14634            public JournalArticle findByG_ST_First(long groupId, int status,
14635                    OrderByComparator orderByComparator)
14636                    throws NoSuchArticleException, SystemException {
14637                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
14638                                    orderByComparator);
14639    
14640                    if (journalArticle != null) {
14641                            return journalArticle;
14642                    }
14643    
14644                    StringBundler msg = new StringBundler(6);
14645    
14646                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14647    
14648                    msg.append("groupId=");
14649                    msg.append(groupId);
14650    
14651                    msg.append(", status=");
14652                    msg.append(status);
14653    
14654                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14655    
14656                    throw new NoSuchArticleException(msg.toString());
14657            }
14658    
14659            /**
14660             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14661             *
14662             * @param groupId the group ID
14663             * @param status the status
14664             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14665             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14666             * @throws SystemException if a system exception occurred
14667             */
14668            @Override
14669            public JournalArticle fetchByG_ST_First(long groupId, int status,
14670                    OrderByComparator orderByComparator) throws SystemException {
14671                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
14672                                    orderByComparator);
14673    
14674                    if (!list.isEmpty()) {
14675                            return list.get(0);
14676                    }
14677    
14678                    return null;
14679            }
14680    
14681            /**
14682             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14683             *
14684             * @param groupId the group ID
14685             * @param status the status
14686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14687             * @return the last matching journal article
14688             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14689             * @throws SystemException if a system exception occurred
14690             */
14691            @Override
14692            public JournalArticle findByG_ST_Last(long groupId, int status,
14693                    OrderByComparator orderByComparator)
14694                    throws NoSuchArticleException, SystemException {
14695                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
14696                                    orderByComparator);
14697    
14698                    if (journalArticle != null) {
14699                            return journalArticle;
14700                    }
14701    
14702                    StringBundler msg = new StringBundler(6);
14703    
14704                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14705    
14706                    msg.append("groupId=");
14707                    msg.append(groupId);
14708    
14709                    msg.append(", status=");
14710                    msg.append(status);
14711    
14712                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14713    
14714                    throw new NoSuchArticleException(msg.toString());
14715            }
14716    
14717            /**
14718             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14719             *
14720             * @param groupId the group ID
14721             * @param status the status
14722             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14723             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14724             * @throws SystemException if a system exception occurred
14725             */
14726            @Override
14727            public JournalArticle fetchByG_ST_Last(long groupId, int status,
14728                    OrderByComparator orderByComparator) throws SystemException {
14729                    int count = countByG_ST(groupId, status);
14730    
14731                    if (count == 0) {
14732                            return null;
14733                    }
14734    
14735                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
14736                                    count, orderByComparator);
14737    
14738                    if (!list.isEmpty()) {
14739                            return list.get(0);
14740                    }
14741    
14742                    return null;
14743            }
14744    
14745            /**
14746             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
14747             *
14748             * @param id the primary key of the current journal article
14749             * @param groupId the group ID
14750             * @param status the status
14751             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14752             * @return the previous, current, and next journal article
14753             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14754             * @throws SystemException if a system exception occurred
14755             */
14756            @Override
14757            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
14758                    int status, OrderByComparator orderByComparator)
14759                    throws NoSuchArticleException, SystemException {
14760                    JournalArticle journalArticle = findByPrimaryKey(id);
14761    
14762                    Session session = null;
14763    
14764                    try {
14765                            session = openSession();
14766    
14767                            JournalArticle[] array = new JournalArticleImpl[3];
14768    
14769                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14770                                            status, orderByComparator, true);
14771    
14772                            array[1] = journalArticle;
14773    
14774                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14775                                            status, orderByComparator, false);
14776    
14777                            return array;
14778                    }
14779                    catch (Exception e) {
14780                            throw processException(e);
14781                    }
14782                    finally {
14783                            closeSession(session);
14784                    }
14785            }
14786    
14787            protected JournalArticle getByG_ST_PrevAndNext(Session session,
14788                    JournalArticle journalArticle, long groupId, int status,
14789                    OrderByComparator orderByComparator, boolean previous) {
14790                    StringBundler query = null;
14791    
14792                    if (orderByComparator != null) {
14793                            query = new StringBundler(6 +
14794                                            (orderByComparator.getOrderByFields().length * 6));
14795                    }
14796                    else {
14797                            query = new StringBundler(3);
14798                    }
14799    
14800                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14801    
14802                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14803    
14804                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14805    
14806                    if (orderByComparator != null) {
14807                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14808    
14809                            if (orderByConditionFields.length > 0) {
14810                                    query.append(WHERE_AND);
14811                            }
14812    
14813                            for (int i = 0; i < orderByConditionFields.length; i++) {
14814                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14815                                    query.append(orderByConditionFields[i]);
14816    
14817                                    if ((i + 1) < orderByConditionFields.length) {
14818                                            if (orderByComparator.isAscending() ^ previous) {
14819                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14820                                            }
14821                                            else {
14822                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14823                                            }
14824                                    }
14825                                    else {
14826                                            if (orderByComparator.isAscending() ^ previous) {
14827                                                    query.append(WHERE_GREATER_THAN);
14828                                            }
14829                                            else {
14830                                                    query.append(WHERE_LESSER_THAN);
14831                                            }
14832                                    }
14833                            }
14834    
14835                            query.append(ORDER_BY_CLAUSE);
14836    
14837                            String[] orderByFields = orderByComparator.getOrderByFields();
14838    
14839                            for (int i = 0; i < orderByFields.length; i++) {
14840                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14841                                    query.append(orderByFields[i]);
14842    
14843                                    if ((i + 1) < orderByFields.length) {
14844                                            if (orderByComparator.isAscending() ^ previous) {
14845                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14846                                            }
14847                                            else {
14848                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14849                                            }
14850                                    }
14851                                    else {
14852                                            if (orderByComparator.isAscending() ^ previous) {
14853                                                    query.append(ORDER_BY_ASC);
14854                                            }
14855                                            else {
14856                                                    query.append(ORDER_BY_DESC);
14857                                            }
14858                                    }
14859                            }
14860                    }
14861                    else {
14862                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14863                    }
14864    
14865                    String sql = query.toString();
14866    
14867                    Query q = session.createQuery(sql);
14868    
14869                    q.setFirstResult(0);
14870                    q.setMaxResults(2);
14871    
14872                    QueryPos qPos = QueryPos.getInstance(q);
14873    
14874                    qPos.add(groupId);
14875    
14876                    qPos.add(status);
14877    
14878                    if (orderByComparator != null) {
14879                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14880    
14881                            for (Object value : values) {
14882                                    qPos.add(value);
14883                            }
14884                    }
14885    
14886                    List<JournalArticle> list = q.list();
14887    
14888                    if (list.size() == 2) {
14889                            return list.get(1);
14890                    }
14891                    else {
14892                            return null;
14893                    }
14894            }
14895    
14896            /**
14897             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14898             *
14899             * @param groupId the group ID
14900             * @param status the status
14901             * @return the matching journal articles that the user has permission to view
14902             * @throws SystemException if a system exception occurred
14903             */
14904            @Override
14905            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
14906                    throws SystemException {
14907                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
14908                            QueryUtil.ALL_POS, null);
14909            }
14910    
14911            /**
14912             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14913             *
14914             * <p>
14915             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14916             * </p>
14917             *
14918             * @param groupId the group ID
14919             * @param status the status
14920             * @param start the lower bound of the range of journal articles
14921             * @param end the upper bound of the range of journal articles (not inclusive)
14922             * @return the range of 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_ST(long groupId, int status,
14927                    int start, int end) throws SystemException {
14928                    return filterFindByG_ST(groupId, status, start, end, null);
14929            }
14930    
14931            /**
14932             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
14933             *
14934             * <p>
14935             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14936             * </p>
14937             *
14938             * @param groupId the group ID
14939             * @param status the status
14940             * @param start the lower bound of the range of journal articles
14941             * @param end the upper bound of the range of journal articles (not inclusive)
14942             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14943             * @return the ordered 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_ST(long groupId, int status,
14948                    int start, int end, OrderByComparator orderByComparator)
14949                    throws SystemException {
14950                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14951                            return findByG_ST(groupId, status, start, end, orderByComparator);
14952                    }
14953    
14954                    StringBundler query = null;
14955    
14956                    if (orderByComparator != null) {
14957                            query = new StringBundler(4 +
14958                                            (orderByComparator.getOrderByFields().length * 3));
14959                    }
14960                    else {
14961                            query = new StringBundler(4);
14962                    }
14963    
14964                    if (getDB().isSupportsInlineDistinct()) {
14965                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14966                    }
14967                    else {
14968                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14969                    }
14970    
14971                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14972    
14973                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14974    
14975                    if (!getDB().isSupportsInlineDistinct()) {
14976                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14977                    }
14978    
14979                    if (orderByComparator != null) {
14980                            if (getDB().isSupportsInlineDistinct()) {
14981                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14982                                            orderByComparator, true);
14983                            }
14984                            else {
14985                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14986                                            orderByComparator, true);
14987                            }
14988                    }
14989                    else {
14990                            if (getDB().isSupportsInlineDistinct()) {
14991                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14992                            }
14993                            else {
14994                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14995                            }
14996                    }
14997    
14998                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14999                                    JournalArticle.class.getName(),
15000                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15001    
15002                    Session session = null;
15003    
15004                    try {
15005                            session = openSession();
15006    
15007                            SQLQuery q = session.createSQLQuery(sql);
15008    
15009                            if (getDB().isSupportsInlineDistinct()) {
15010                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15011                            }
15012                            else {
15013                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15014                            }
15015    
15016                            QueryPos qPos = QueryPos.getInstance(q);
15017    
15018                            qPos.add(groupId);
15019    
15020                            qPos.add(status);
15021    
15022                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15023                                    end);
15024                    }
15025                    catch (Exception e) {
15026                            throw processException(e);
15027                    }
15028                    finally {
15029                            closeSession(session);
15030                    }
15031            }
15032    
15033            /**
15034             * 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;.
15035             *
15036             * @param id the primary key of the current journal article
15037             * @param groupId the group ID
15038             * @param status the status
15039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15040             * @return the previous, current, and next journal article
15041             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15042             * @throws SystemException if a system exception occurred
15043             */
15044            @Override
15045            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
15046                    int status, OrderByComparator orderByComparator)
15047                    throws NoSuchArticleException, SystemException {
15048                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15049                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
15050                    }
15051    
15052                    JournalArticle journalArticle = findByPrimaryKey(id);
15053    
15054                    Session session = null;
15055    
15056                    try {
15057                            session = openSession();
15058    
15059                            JournalArticle[] array = new JournalArticleImpl[3];
15060    
15061                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
15062                                            groupId, status, orderByComparator, true);
15063    
15064                            array[1] = journalArticle;
15065    
15066                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
15067                                            groupId, status, orderByComparator, false);
15068    
15069                            return array;
15070                    }
15071                    catch (Exception e) {
15072                            throw processException(e);
15073                    }
15074                    finally {
15075                            closeSession(session);
15076                    }
15077            }
15078    
15079            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
15080                    JournalArticle journalArticle, long groupId, int status,
15081                    OrderByComparator orderByComparator, boolean previous) {
15082                    StringBundler query = null;
15083    
15084                    if (orderByComparator != null) {
15085                            query = new StringBundler(6 +
15086                                            (orderByComparator.getOrderByFields().length * 6));
15087                    }
15088                    else {
15089                            query = new StringBundler(3);
15090                    }
15091    
15092                    if (getDB().isSupportsInlineDistinct()) {
15093                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15094                    }
15095                    else {
15096                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15097                    }
15098    
15099                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15100    
15101                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15102    
15103                    if (!getDB().isSupportsInlineDistinct()) {
15104                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15105                    }
15106    
15107                    if (orderByComparator != null) {
15108                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15109    
15110                            if (orderByConditionFields.length > 0) {
15111                                    query.append(WHERE_AND);
15112                            }
15113    
15114                            for (int i = 0; i < orderByConditionFields.length; i++) {
15115                                    if (getDB().isSupportsInlineDistinct()) {
15116                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15117                                    }
15118                                    else {
15119                                            query.append(_ORDER_BY_ENTITY_TABLE);
15120                                    }
15121    
15122                                    query.append(orderByConditionFields[i]);
15123    
15124                                    if ((i + 1) < orderByConditionFields.length) {
15125                                            if (orderByComparator.isAscending() ^ previous) {
15126                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15127                                            }
15128                                            else {
15129                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15130                                            }
15131                                    }
15132                                    else {
15133                                            if (orderByComparator.isAscending() ^ previous) {
15134                                                    query.append(WHERE_GREATER_THAN);
15135                                            }
15136                                            else {
15137                                                    query.append(WHERE_LESSER_THAN);
15138                                            }
15139                                    }
15140                            }
15141    
15142                            query.append(ORDER_BY_CLAUSE);
15143    
15144                            String[] orderByFields = orderByComparator.getOrderByFields();
15145    
15146                            for (int i = 0; i < orderByFields.length; i++) {
15147                                    if (getDB().isSupportsInlineDistinct()) {
15148                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15149                                    }
15150                                    else {
15151                                            query.append(_ORDER_BY_ENTITY_TABLE);
15152                                    }
15153    
15154                                    query.append(orderByFields[i]);
15155    
15156                                    if ((i + 1) < orderByFields.length) {
15157                                            if (orderByComparator.isAscending() ^ previous) {
15158                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15159                                            }
15160                                            else {
15161                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15162                                            }
15163                                    }
15164                                    else {
15165                                            if (orderByComparator.isAscending() ^ previous) {
15166                                                    query.append(ORDER_BY_ASC);
15167                                            }
15168                                            else {
15169                                                    query.append(ORDER_BY_DESC);
15170                                            }
15171                                    }
15172                            }
15173                    }
15174                    else {
15175                            if (getDB().isSupportsInlineDistinct()) {
15176                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15177                            }
15178                            else {
15179                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15180                            }
15181                    }
15182    
15183                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15184                                    JournalArticle.class.getName(),
15185                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15186    
15187                    SQLQuery q = session.createSQLQuery(sql);
15188    
15189                    q.setFirstResult(0);
15190                    q.setMaxResults(2);
15191    
15192                    if (getDB().isSupportsInlineDistinct()) {
15193                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15194                    }
15195                    else {
15196                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15197                    }
15198    
15199                    QueryPos qPos = QueryPos.getInstance(q);
15200    
15201                    qPos.add(groupId);
15202    
15203                    qPos.add(status);
15204    
15205                    if (orderByComparator != null) {
15206                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15207    
15208                            for (Object value : values) {
15209                                    qPos.add(value);
15210                            }
15211                    }
15212    
15213                    List<JournalArticle> list = q.list();
15214    
15215                    if (list.size() == 2) {
15216                            return list.get(1);
15217                    }
15218                    else {
15219                            return null;
15220                    }
15221            }
15222    
15223            /**
15224             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
15225             *
15226             * @param groupId the group ID
15227             * @param status the status
15228             * @throws SystemException if a system exception occurred
15229             */
15230            @Override
15231            public void removeByG_ST(long groupId, int status)
15232                    throws SystemException {
15233                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
15234                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15235                            remove(journalArticle);
15236                    }
15237            }
15238    
15239            /**
15240             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
15241             *
15242             * @param groupId the group ID
15243             * @param status the status
15244             * @return the number of matching journal articles
15245             * @throws SystemException if a system exception occurred
15246             */
15247            @Override
15248            public int countByG_ST(long groupId, int status) throws SystemException {
15249                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
15250    
15251                    Object[] finderArgs = new Object[] { groupId, status };
15252    
15253                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15254                                    this);
15255    
15256                    if (count == null) {
15257                            StringBundler query = new StringBundler(3);
15258    
15259                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15260    
15261                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15262    
15263                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15264    
15265                            String sql = query.toString();
15266    
15267                            Session session = null;
15268    
15269                            try {
15270                                    session = openSession();
15271    
15272                                    Query q = session.createQuery(sql);
15273    
15274                                    QueryPos qPos = QueryPos.getInstance(q);
15275    
15276                                    qPos.add(groupId);
15277    
15278                                    qPos.add(status);
15279    
15280                                    count = (Long)q.uniqueResult();
15281    
15282                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15283                            }
15284                            catch (Exception e) {
15285                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15286    
15287                                    throw processException(e);
15288                            }
15289                            finally {
15290                                    closeSession(session);
15291                            }
15292                    }
15293    
15294                    return count.intValue();
15295            }
15296    
15297            /**
15298             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
15299             *
15300             * @param groupId the group ID
15301             * @param status the status
15302             * @return the number of matching journal articles that the user has permission to view
15303             * @throws SystemException if a system exception occurred
15304             */
15305            @Override
15306            public int filterCountByG_ST(long groupId, int status)
15307                    throws SystemException {
15308                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15309                            return countByG_ST(groupId, status);
15310                    }
15311    
15312                    StringBundler query = new StringBundler(3);
15313    
15314                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15315    
15316                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15317    
15318                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15319    
15320                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15321                                    JournalArticle.class.getName(),
15322                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15323    
15324                    Session session = null;
15325    
15326                    try {
15327                            session = openSession();
15328    
15329                            SQLQuery q = session.createSQLQuery(sql);
15330    
15331                            q.addScalar(COUNT_COLUMN_NAME,
15332                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15333    
15334                            QueryPos qPos = QueryPos.getInstance(q);
15335    
15336                            qPos.add(groupId);
15337    
15338                            qPos.add(status);
15339    
15340                            Long count = (Long)q.uniqueResult();
15341    
15342                            return count.intValue();
15343                    }
15344                    catch (Exception e) {
15345                            throw processException(e);
15346                    }
15347                    finally {
15348                            closeSession(session);
15349                    }
15350            }
15351    
15352            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
15353            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
15354            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15355                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15356                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15357                            "findByC_V",
15358                            new String[] {
15359                                    Long.class.getName(), Double.class.getName(),
15360                                    
15361                            Integer.class.getName(), Integer.class.getName(),
15362                                    OrderByComparator.class.getName()
15363                            });
15364            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15365                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15366                            JournalArticleImpl.class,
15367                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
15368                            new String[] { Long.class.getName(), Double.class.getName() },
15369                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15370                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
15371                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
15372            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15373                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15374                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
15375                            new String[] { Long.class.getName(), Double.class.getName() });
15376    
15377            /**
15378             * Returns all the journal articles where companyId = &#63; and version = &#63;.
15379             *
15380             * @param companyId the company ID
15381             * @param version the version
15382             * @return the matching journal articles
15383             * @throws SystemException if a system exception occurred
15384             */
15385            @Override
15386            public List<JournalArticle> findByC_V(long companyId, double version)
15387                    throws SystemException {
15388                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
15389                            QueryUtil.ALL_POS, null);
15390            }
15391    
15392            /**
15393             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
15394             *
15395             * <p>
15396             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15397             * </p>
15398             *
15399             * @param companyId the company ID
15400             * @param version the version
15401             * @param start the lower bound of the range of journal articles
15402             * @param end the upper bound of the range of journal articles (not inclusive)
15403             * @return the range of matching journal articles
15404             * @throws SystemException if a system exception occurred
15405             */
15406            @Override
15407            public List<JournalArticle> findByC_V(long companyId, double version,
15408                    int start, int end) throws SystemException {
15409                    return findByC_V(companyId, version, start, end, null);
15410            }
15411    
15412            /**
15413             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
15414             *
15415             * <p>
15416             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15417             * </p>
15418             *
15419             * @param companyId the company ID
15420             * @param version the version
15421             * @param start the lower bound of the range of journal articles
15422             * @param end the upper bound of the range of journal articles (not inclusive)
15423             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15424             * @return the ordered range of matching journal articles
15425             * @throws SystemException if a system exception occurred
15426             */
15427            @Override
15428            public List<JournalArticle> findByC_V(long companyId, double version,
15429                    int start, int end, OrderByComparator orderByComparator)
15430                    throws SystemException {
15431                    boolean pagination = true;
15432                    FinderPath finderPath = null;
15433                    Object[] finderArgs = null;
15434    
15435                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15436                                    (orderByComparator == null)) {
15437                            pagination = false;
15438                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
15439                            finderArgs = new Object[] { companyId, version };
15440                    }
15441                    else {
15442                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
15443                            finderArgs = new Object[] {
15444                                            companyId, version,
15445                                            
15446                                            start, end, orderByComparator
15447                                    };
15448                    }
15449    
15450                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15451                                    finderArgs, this);
15452    
15453                    if ((list != null) && !list.isEmpty()) {
15454                            for (JournalArticle journalArticle : list) {
15455                                    if ((companyId != journalArticle.getCompanyId()) ||
15456                                                    (version != journalArticle.getVersion())) {
15457                                            list = null;
15458    
15459                                            break;
15460                                    }
15461                            }
15462                    }
15463    
15464                    if (list == null) {
15465                            StringBundler query = null;
15466    
15467                            if (orderByComparator != null) {
15468                                    query = new StringBundler(4 +
15469                                                    (orderByComparator.getOrderByFields().length * 3));
15470                            }
15471                            else {
15472                                    query = new StringBundler(4);
15473                            }
15474    
15475                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15476    
15477                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15478    
15479                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15480    
15481                            if (orderByComparator != null) {
15482                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15483                                            orderByComparator);
15484                            }
15485                            else
15486                             if (pagination) {
15487                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15488                            }
15489    
15490                            String sql = query.toString();
15491    
15492                            Session session = null;
15493    
15494                            try {
15495                                    session = openSession();
15496    
15497                                    Query q = session.createQuery(sql);
15498    
15499                                    QueryPos qPos = QueryPos.getInstance(q);
15500    
15501                                    qPos.add(companyId);
15502    
15503                                    qPos.add(version);
15504    
15505                                    if (!pagination) {
15506                                            list = (List<JournalArticle>)QueryUtil.list(q,
15507                                                            getDialect(), start, end, false);
15508    
15509                                            Collections.sort(list);
15510    
15511                                            list = new UnmodifiableList<JournalArticle>(list);
15512                                    }
15513                                    else {
15514                                            list = (List<JournalArticle>)QueryUtil.list(q,
15515                                                            getDialect(), start, end);
15516                                    }
15517    
15518                                    cacheResult(list);
15519    
15520                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15521                            }
15522                            catch (Exception e) {
15523                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15524    
15525                                    throw processException(e);
15526                            }
15527                            finally {
15528                                    closeSession(session);
15529                            }
15530                    }
15531    
15532                    return list;
15533            }
15534    
15535            /**
15536             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15537             *
15538             * @param companyId the company ID
15539             * @param version the version
15540             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15541             * @return the first matching journal article
15542             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15543             * @throws SystemException if a system exception occurred
15544             */
15545            @Override
15546            public JournalArticle findByC_V_First(long companyId, double version,
15547                    OrderByComparator orderByComparator)
15548                    throws NoSuchArticleException, SystemException {
15549                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
15550                                    orderByComparator);
15551    
15552                    if (journalArticle != null) {
15553                            return journalArticle;
15554                    }
15555    
15556                    StringBundler msg = new StringBundler(6);
15557    
15558                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15559    
15560                    msg.append("companyId=");
15561                    msg.append(companyId);
15562    
15563                    msg.append(", version=");
15564                    msg.append(version);
15565    
15566                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15567    
15568                    throw new NoSuchArticleException(msg.toString());
15569            }
15570    
15571            /**
15572             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15573             *
15574             * @param companyId the company ID
15575             * @param version the version
15576             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15577             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15578             * @throws SystemException if a system exception occurred
15579             */
15580            @Override
15581            public JournalArticle fetchByC_V_First(long companyId, double version,
15582                    OrderByComparator orderByComparator) throws SystemException {
15583                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
15584                                    orderByComparator);
15585    
15586                    if (!list.isEmpty()) {
15587                            return list.get(0);
15588                    }
15589    
15590                    return null;
15591            }
15592    
15593            /**
15594             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15595             *
15596             * @param companyId the company ID
15597             * @param version the version
15598             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15599             * @return the last matching journal article
15600             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15601             * @throws SystemException if a system exception occurred
15602             */
15603            @Override
15604            public JournalArticle findByC_V_Last(long companyId, double version,
15605                    OrderByComparator orderByComparator)
15606                    throws NoSuchArticleException, SystemException {
15607                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
15608                                    orderByComparator);
15609    
15610                    if (journalArticle != null) {
15611                            return journalArticle;
15612                    }
15613    
15614                    StringBundler msg = new StringBundler(6);
15615    
15616                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15617    
15618                    msg.append("companyId=");
15619                    msg.append(companyId);
15620    
15621                    msg.append(", version=");
15622                    msg.append(version);
15623    
15624                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15625    
15626                    throw new NoSuchArticleException(msg.toString());
15627            }
15628    
15629            /**
15630             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15631             *
15632             * @param companyId the company ID
15633             * @param version the version
15634             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15635             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15636             * @throws SystemException if a system exception occurred
15637             */
15638            @Override
15639            public JournalArticle fetchByC_V_Last(long companyId, double version,
15640                    OrderByComparator orderByComparator) throws SystemException {
15641                    int count = countByC_V(companyId, version);
15642    
15643                    if (count == 0) {
15644                            return null;
15645                    }
15646    
15647                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
15648                                    count, orderByComparator);
15649    
15650                    if (!list.isEmpty()) {
15651                            return list.get(0);
15652                    }
15653    
15654                    return null;
15655            }
15656    
15657            /**
15658             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
15659             *
15660             * @param id the primary key of the current journal article
15661             * @param companyId the company ID
15662             * @param version the version
15663             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15664             * @return the previous, current, and next journal article
15665             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15666             * @throws SystemException if a system exception occurred
15667             */
15668            @Override
15669            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
15670                    double version, OrderByComparator orderByComparator)
15671                    throws NoSuchArticleException, SystemException {
15672                    JournalArticle journalArticle = findByPrimaryKey(id);
15673    
15674                    Session session = null;
15675    
15676                    try {
15677                            session = openSession();
15678    
15679                            JournalArticle[] array = new JournalArticleImpl[3];
15680    
15681                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15682                                            version, orderByComparator, true);
15683    
15684                            array[1] = journalArticle;
15685    
15686                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15687                                            version, orderByComparator, false);
15688    
15689                            return array;
15690                    }
15691                    catch (Exception e) {
15692                            throw processException(e);
15693                    }
15694                    finally {
15695                            closeSession(session);
15696                    }
15697            }
15698    
15699            protected JournalArticle getByC_V_PrevAndNext(Session session,
15700                    JournalArticle journalArticle, long companyId, double version,
15701                    OrderByComparator orderByComparator, boolean previous) {
15702                    StringBundler query = null;
15703    
15704                    if (orderByComparator != null) {
15705                            query = new StringBundler(6 +
15706                                            (orderByComparator.getOrderByFields().length * 6));
15707                    }
15708                    else {
15709                            query = new StringBundler(3);
15710                    }
15711    
15712                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15713    
15714                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15715    
15716                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
15717    
15718                    if (orderByComparator != null) {
15719                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15720    
15721                            if (orderByConditionFields.length > 0) {
15722                                    query.append(WHERE_AND);
15723                            }
15724    
15725                            for (int i = 0; i < orderByConditionFields.length; i++) {
15726                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15727                                    query.append(orderByConditionFields[i]);
15728    
15729                                    if ((i + 1) < orderByConditionFields.length) {
15730                                            if (orderByComparator.isAscending() ^ previous) {
15731                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15732                                            }
15733                                            else {
15734                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15735                                            }
15736                                    }
15737                                    else {
15738                                            if (orderByComparator.isAscending() ^ previous) {
15739                                                    query.append(WHERE_GREATER_THAN);
15740                                            }
15741                                            else {
15742                                                    query.append(WHERE_LESSER_THAN);
15743                                            }
15744                                    }
15745                            }
15746    
15747                            query.append(ORDER_BY_CLAUSE);
15748    
15749                            String[] orderByFields = orderByComparator.getOrderByFields();
15750    
15751                            for (int i = 0; i < orderByFields.length; i++) {
15752                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15753                                    query.append(orderByFields[i]);
15754    
15755                                    if ((i + 1) < orderByFields.length) {
15756                                            if (orderByComparator.isAscending() ^ previous) {
15757                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15758                                            }
15759                                            else {
15760                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15761                                            }
15762                                    }
15763                                    else {
15764                                            if (orderByComparator.isAscending() ^ previous) {
15765                                                    query.append(ORDER_BY_ASC);
15766                                            }
15767                                            else {
15768                                                    query.append(ORDER_BY_DESC);
15769                                            }
15770                                    }
15771                            }
15772                    }
15773                    else {
15774                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15775                    }
15776    
15777                    String sql = query.toString();
15778    
15779                    Query q = session.createQuery(sql);
15780    
15781                    q.setFirstResult(0);
15782                    q.setMaxResults(2);
15783    
15784                    QueryPos qPos = QueryPos.getInstance(q);
15785    
15786                    qPos.add(companyId);
15787    
15788                    qPos.add(version);
15789    
15790                    if (orderByComparator != null) {
15791                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15792    
15793                            for (Object value : values) {
15794                                    qPos.add(value);
15795                            }
15796                    }
15797    
15798                    List<JournalArticle> list = q.list();
15799    
15800                    if (list.size() == 2) {
15801                            return list.get(1);
15802                    }
15803                    else {
15804                            return null;
15805                    }
15806            }
15807    
15808            /**
15809             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
15810             *
15811             * @param companyId the company ID
15812             * @param version the version
15813             * @throws SystemException if a system exception occurred
15814             */
15815            @Override
15816            public void removeByC_V(long companyId, double version)
15817                    throws SystemException {
15818                    for (JournalArticle journalArticle : findByC_V(companyId, version,
15819                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15820                            remove(journalArticle);
15821                    }
15822            }
15823    
15824            /**
15825             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15826             *
15827             * @param companyId the company ID
15828             * @param version the version
15829             * @return the number of matching journal articles
15830             * @throws SystemException if a system exception occurred
15831             */
15832            @Override
15833            public int countByC_V(long companyId, double version)
15834                    throws SystemException {
15835                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
15836    
15837                    Object[] finderArgs = new Object[] { companyId, version };
15838    
15839                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15840                                    this);
15841    
15842                    if (count == null) {
15843                            StringBundler query = new StringBundler(3);
15844    
15845                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15846    
15847                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15848    
15849                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15850    
15851                            String sql = query.toString();
15852    
15853                            Session session = null;
15854    
15855                            try {
15856                                    session = openSession();
15857    
15858                                    Query q = session.createQuery(sql);
15859    
15860                                    QueryPos qPos = QueryPos.getInstance(q);
15861    
15862                                    qPos.add(companyId);
15863    
15864                                    qPos.add(version);
15865    
15866                                    count = (Long)q.uniqueResult();
15867    
15868                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15869                            }
15870                            catch (Exception e) {
15871                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15872    
15873                                    throw processException(e);
15874                            }
15875                            finally {
15876                                    closeSession(session);
15877                            }
15878                    }
15879    
15880                    return count.intValue();
15881            }
15882    
15883            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15884            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
15885            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15886                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15887                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15888                            "findByC_ST",
15889                            new String[] {
15890                                    Long.class.getName(), Integer.class.getName(),
15891                                    
15892                            Integer.class.getName(), Integer.class.getName(),
15893                                    OrderByComparator.class.getName()
15894                            });
15895            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15896                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15897                            JournalArticleImpl.class,
15898                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
15899                            new String[] { Long.class.getName(), Integer.class.getName() },
15900                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15901                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
15902                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
15903                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
15904            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15905                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15906                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
15907                            new String[] { Long.class.getName(), Integer.class.getName() });
15908    
15909            /**
15910             * Returns all the journal articles where companyId = &#63; and status = &#63;.
15911             *
15912             * @param companyId the company ID
15913             * @param status the status
15914             * @return the matching journal articles
15915             * @throws SystemException if a system exception occurred
15916             */
15917            @Override
15918            public List<JournalArticle> findByC_ST(long companyId, int status)
15919                    throws SystemException {
15920                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
15921                            QueryUtil.ALL_POS, null);
15922            }
15923    
15924            /**
15925             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
15926             *
15927             * <p>
15928             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15929             * </p>
15930             *
15931             * @param companyId the company ID
15932             * @param status the status
15933             * @param start the lower bound of the range of journal articles
15934             * @param end the upper bound of the range of journal articles (not inclusive)
15935             * @return the range of matching journal articles
15936             * @throws SystemException if a system exception occurred
15937             */
15938            @Override
15939            public List<JournalArticle> findByC_ST(long companyId, int status,
15940                    int start, int end) throws SystemException {
15941                    return findByC_ST(companyId, status, start, end, null);
15942            }
15943    
15944            /**
15945             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
15946             *
15947             * <p>
15948             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15949             * </p>
15950             *
15951             * @param companyId the company ID
15952             * @param status the status
15953             * @param start the lower bound of the range of journal articles
15954             * @param end the upper bound of the range of journal articles (not inclusive)
15955             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15956             * @return the ordered range of matching journal articles
15957             * @throws SystemException if a system exception occurred
15958             */
15959            @Override
15960            public List<JournalArticle> findByC_ST(long companyId, int status,
15961                    int start, int end, OrderByComparator orderByComparator)
15962                    throws SystemException {
15963                    boolean pagination = true;
15964                    FinderPath finderPath = null;
15965                    Object[] finderArgs = null;
15966    
15967                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15968                                    (orderByComparator == null)) {
15969                            pagination = false;
15970                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
15971                            finderArgs = new Object[] { companyId, status };
15972                    }
15973                    else {
15974                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
15975                            finderArgs = new Object[] {
15976                                            companyId, status,
15977                                            
15978                                            start, end, orderByComparator
15979                                    };
15980                    }
15981    
15982                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15983                                    finderArgs, this);
15984    
15985                    if ((list != null) && !list.isEmpty()) {
15986                            for (JournalArticle journalArticle : list) {
15987                                    if ((companyId != journalArticle.getCompanyId()) ||
15988                                                    (status != journalArticle.getStatus())) {
15989                                            list = null;
15990    
15991                                            break;
15992                                    }
15993                            }
15994                    }
15995    
15996                    if (list == null) {
15997                            StringBundler query = null;
15998    
15999                            if (orderByComparator != null) {
16000                                    query = new StringBundler(4 +
16001                                                    (orderByComparator.getOrderByFields().length * 3));
16002                            }
16003                            else {
16004                                    query = new StringBundler(4);
16005                            }
16006    
16007                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16008    
16009                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16010    
16011                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16012    
16013                            if (orderByComparator != null) {
16014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16015                                            orderByComparator);
16016                            }
16017                            else
16018                             if (pagination) {
16019                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16020                            }
16021    
16022                            String sql = query.toString();
16023    
16024                            Session session = null;
16025    
16026                            try {
16027                                    session = openSession();
16028    
16029                                    Query q = session.createQuery(sql);
16030    
16031                                    QueryPos qPos = QueryPos.getInstance(q);
16032    
16033                                    qPos.add(companyId);
16034    
16035                                    qPos.add(status);
16036    
16037                                    if (!pagination) {
16038                                            list = (List<JournalArticle>)QueryUtil.list(q,
16039                                                            getDialect(), start, end, false);
16040    
16041                                            Collections.sort(list);
16042    
16043                                            list = new UnmodifiableList<JournalArticle>(list);
16044                                    }
16045                                    else {
16046                                            list = (List<JournalArticle>)QueryUtil.list(q,
16047                                                            getDialect(), start, end);
16048                                    }
16049    
16050                                    cacheResult(list);
16051    
16052                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16053                            }
16054                            catch (Exception e) {
16055                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16056    
16057                                    throw processException(e);
16058                            }
16059                            finally {
16060                                    closeSession(session);
16061                            }
16062                    }
16063    
16064                    return list;
16065            }
16066    
16067            /**
16068             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
16069             *
16070             * @param companyId the company ID
16071             * @param status the status
16072             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16073             * @return the first matching journal article
16074             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16075             * @throws SystemException if a system exception occurred
16076             */
16077            @Override
16078            public JournalArticle findByC_ST_First(long companyId, int status,
16079                    OrderByComparator orderByComparator)
16080                    throws NoSuchArticleException, SystemException {
16081                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
16082                                    orderByComparator);
16083    
16084                    if (journalArticle != null) {
16085                            return journalArticle;
16086                    }
16087    
16088                    StringBundler msg = new StringBundler(6);
16089    
16090                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16091    
16092                    msg.append("companyId=");
16093                    msg.append(companyId);
16094    
16095                    msg.append(", status=");
16096                    msg.append(status);
16097    
16098                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16099    
16100                    throw new NoSuchArticleException(msg.toString());
16101            }
16102    
16103            /**
16104             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
16105             *
16106             * @param companyId the company ID
16107             * @param status the status
16108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16109             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16110             * @throws SystemException if a system exception occurred
16111             */
16112            @Override
16113            public JournalArticle fetchByC_ST_First(long companyId, int status,
16114                    OrderByComparator orderByComparator) throws SystemException {
16115                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
16116                                    orderByComparator);
16117    
16118                    if (!list.isEmpty()) {
16119                            return list.get(0);
16120                    }
16121    
16122                    return null;
16123            }
16124    
16125            /**
16126             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
16127             *
16128             * @param companyId the company ID
16129             * @param status the status
16130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16131             * @return the last matching journal article
16132             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16133             * @throws SystemException if a system exception occurred
16134             */
16135            @Override
16136            public JournalArticle findByC_ST_Last(long companyId, int status,
16137                    OrderByComparator orderByComparator)
16138                    throws NoSuchArticleException, SystemException {
16139                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
16140                                    orderByComparator);
16141    
16142                    if (journalArticle != null) {
16143                            return journalArticle;
16144                    }
16145    
16146                    StringBundler msg = new StringBundler(6);
16147    
16148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16149    
16150                    msg.append("companyId=");
16151                    msg.append(companyId);
16152    
16153                    msg.append(", status=");
16154                    msg.append(status);
16155    
16156                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16157    
16158                    throw new NoSuchArticleException(msg.toString());
16159            }
16160    
16161            /**
16162             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
16163             *
16164             * @param companyId the company ID
16165             * @param status the status
16166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16167             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16168             * @throws SystemException if a system exception occurred
16169             */
16170            @Override
16171            public JournalArticle fetchByC_ST_Last(long companyId, int status,
16172                    OrderByComparator orderByComparator) throws SystemException {
16173                    int count = countByC_ST(companyId, status);
16174    
16175                    if (count == 0) {
16176                            return null;
16177                    }
16178    
16179                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
16180                                    count, orderByComparator);
16181    
16182                    if (!list.isEmpty()) {
16183                            return list.get(0);
16184                    }
16185    
16186                    return null;
16187            }
16188    
16189            /**
16190             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
16191             *
16192             * @param id the primary key of the current journal article
16193             * @param companyId the company ID
16194             * @param status the status
16195             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16196             * @return the previous, current, and next journal article
16197             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16198             * @throws SystemException if a system exception occurred
16199             */
16200            @Override
16201            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
16202                    int status, OrderByComparator orderByComparator)
16203                    throws NoSuchArticleException, SystemException {
16204                    JournalArticle journalArticle = findByPrimaryKey(id);
16205    
16206                    Session session = null;
16207    
16208                    try {
16209                            session = openSession();
16210    
16211                            JournalArticle[] array = new JournalArticleImpl[3];
16212    
16213                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
16214                                            companyId, status, orderByComparator, true);
16215    
16216                            array[1] = journalArticle;
16217    
16218                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
16219                                            companyId, status, orderByComparator, false);
16220    
16221                            return array;
16222                    }
16223                    catch (Exception e) {
16224                            throw processException(e);
16225                    }
16226                    finally {
16227                            closeSession(session);
16228                    }
16229            }
16230    
16231            protected JournalArticle getByC_ST_PrevAndNext(Session session,
16232                    JournalArticle journalArticle, long companyId, int status,
16233                    OrderByComparator orderByComparator, boolean previous) {
16234                    StringBundler query = null;
16235    
16236                    if (orderByComparator != null) {
16237                            query = new StringBundler(6 +
16238                                            (orderByComparator.getOrderByFields().length * 6));
16239                    }
16240                    else {
16241                            query = new StringBundler(3);
16242                    }
16243    
16244                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16245    
16246                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16247    
16248                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16249    
16250                    if (orderByComparator != null) {
16251                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16252    
16253                            if (orderByConditionFields.length > 0) {
16254                                    query.append(WHERE_AND);
16255                            }
16256    
16257                            for (int i = 0; i < orderByConditionFields.length; i++) {
16258                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16259                                    query.append(orderByConditionFields[i]);
16260    
16261                                    if ((i + 1) < orderByConditionFields.length) {
16262                                            if (orderByComparator.isAscending() ^ previous) {
16263                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16264                                            }
16265                                            else {
16266                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16267                                            }
16268                                    }
16269                                    else {
16270                                            if (orderByComparator.isAscending() ^ previous) {
16271                                                    query.append(WHERE_GREATER_THAN);
16272                                            }
16273                                            else {
16274                                                    query.append(WHERE_LESSER_THAN);
16275                                            }
16276                                    }
16277                            }
16278    
16279                            query.append(ORDER_BY_CLAUSE);
16280    
16281                            String[] orderByFields = orderByComparator.getOrderByFields();
16282    
16283                            for (int i = 0; i < orderByFields.length; i++) {
16284                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16285                                    query.append(orderByFields[i]);
16286    
16287                                    if ((i + 1) < orderByFields.length) {
16288                                            if (orderByComparator.isAscending() ^ previous) {
16289                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16290                                            }
16291                                            else {
16292                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16293                                            }
16294                                    }
16295                                    else {
16296                                            if (orderByComparator.isAscending() ^ previous) {
16297                                                    query.append(ORDER_BY_ASC);
16298                                            }
16299                                            else {
16300                                                    query.append(ORDER_BY_DESC);
16301                                            }
16302                                    }
16303                            }
16304                    }
16305                    else {
16306                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16307                    }
16308    
16309                    String sql = query.toString();
16310    
16311                    Query q = session.createQuery(sql);
16312    
16313                    q.setFirstResult(0);
16314                    q.setMaxResults(2);
16315    
16316                    QueryPos qPos = QueryPos.getInstance(q);
16317    
16318                    qPos.add(companyId);
16319    
16320                    qPos.add(status);
16321    
16322                    if (orderByComparator != null) {
16323                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16324    
16325                            for (Object value : values) {
16326                                    qPos.add(value);
16327                            }
16328                    }
16329    
16330                    List<JournalArticle> list = q.list();
16331    
16332                    if (list.size() == 2) {
16333                            return list.get(1);
16334                    }
16335                    else {
16336                            return null;
16337                    }
16338            }
16339    
16340            /**
16341             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
16342             *
16343             * @param companyId the company ID
16344             * @param status the status
16345             * @throws SystemException if a system exception occurred
16346             */
16347            @Override
16348            public void removeByC_ST(long companyId, int status)
16349                    throws SystemException {
16350                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
16351                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16352                            remove(journalArticle);
16353                    }
16354            }
16355    
16356            /**
16357             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
16358             *
16359             * @param companyId the company ID
16360             * @param status the status
16361             * @return the number of matching journal articles
16362             * @throws SystemException if a system exception occurred
16363             */
16364            @Override
16365            public int countByC_ST(long companyId, int status)
16366                    throws SystemException {
16367                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
16368    
16369                    Object[] finderArgs = new Object[] { companyId, status };
16370    
16371                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16372                                    this);
16373    
16374                    if (count == null) {
16375                            StringBundler query = new StringBundler(3);
16376    
16377                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16378    
16379                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16380    
16381                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16382    
16383                            String sql = query.toString();
16384    
16385                            Session session = null;
16386    
16387                            try {
16388                                    session = openSession();
16389    
16390                                    Query q = session.createQuery(sql);
16391    
16392                                    QueryPos qPos = QueryPos.getInstance(q);
16393    
16394                                    qPos.add(companyId);
16395    
16396                                    qPos.add(status);
16397    
16398                                    count = (Long)q.uniqueResult();
16399    
16400                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16401                            }
16402                            catch (Exception e) {
16403                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16404    
16405                                    throw processException(e);
16406                            }
16407                            finally {
16408                                    closeSession(session);
16409                            }
16410                    }
16411    
16412                    return count.intValue();
16413            }
16414    
16415            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16416            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
16417            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16418                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16419                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16420                            "findByC_NotST",
16421                            new String[] {
16422                                    Long.class.getName(), Integer.class.getName(),
16423                                    
16424                            Integer.class.getName(), Integer.class.getName(),
16425                                    OrderByComparator.class.getName()
16426                            });
16427            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16428                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16429                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotST",
16430                            new String[] { Long.class.getName(), Integer.class.getName() });
16431    
16432            /**
16433             * Returns all the journal articles where companyId = &#63; and status &ne; &#63;.
16434             *
16435             * @param companyId the company ID
16436             * @param status the status
16437             * @return the matching journal articles
16438             * @throws SystemException if a system exception occurred
16439             */
16440            @Override
16441            public List<JournalArticle> findByC_NotST(long companyId, int status)
16442                    throws SystemException {
16443                    return findByC_NotST(companyId, status, QueryUtil.ALL_POS,
16444                            QueryUtil.ALL_POS, null);
16445            }
16446    
16447            /**
16448             * Returns a range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16449             *
16450             * <p>
16451             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16452             * </p>
16453             *
16454             * @param companyId the company ID
16455             * @param status the status
16456             * @param start the lower bound of the range of journal articles
16457             * @param end the upper bound of the range of journal articles (not inclusive)
16458             * @return the range of matching journal articles
16459             * @throws SystemException if a system exception occurred
16460             */
16461            @Override
16462            public List<JournalArticle> findByC_NotST(long companyId, int status,
16463                    int start, int end) throws SystemException {
16464                    return findByC_NotST(companyId, status, start, end, null);
16465            }
16466    
16467            /**
16468             * Returns an ordered range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16469             *
16470             * <p>
16471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16472             * </p>
16473             *
16474             * @param companyId the company ID
16475             * @param status the status
16476             * @param start the lower bound of the range of journal articles
16477             * @param end the upper bound of the range of journal articles (not inclusive)
16478             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16479             * @return the ordered range of matching journal articles
16480             * @throws SystemException if a system exception occurred
16481             */
16482            @Override
16483            public List<JournalArticle> findByC_NotST(long companyId, int status,
16484                    int start, int end, OrderByComparator orderByComparator)
16485                    throws SystemException {
16486                    boolean pagination = true;
16487                    FinderPath finderPath = null;
16488                    Object[] finderArgs = null;
16489    
16490                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST;
16491                    finderArgs = new Object[] {
16492                                    companyId, status,
16493                                    
16494                                    start, end, orderByComparator
16495                            };
16496    
16497                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16498                                    finderArgs, this);
16499    
16500                    if ((list != null) && !list.isEmpty()) {
16501                            for (JournalArticle journalArticle : list) {
16502                                    if ((companyId != journalArticle.getCompanyId()) ||
16503                                                    (status == journalArticle.getStatus())) {
16504                                            list = null;
16505    
16506                                            break;
16507                                    }
16508                            }
16509                    }
16510    
16511                    if (list == null) {
16512                            StringBundler query = null;
16513    
16514                            if (orderByComparator != null) {
16515                                    query = new StringBundler(4 +
16516                                                    (orderByComparator.getOrderByFields().length * 3));
16517                            }
16518                            else {
16519                                    query = new StringBundler(4);
16520                            }
16521    
16522                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16523    
16524                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16525    
16526                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16527    
16528                            if (orderByComparator != null) {
16529                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16530                                            orderByComparator);
16531                            }
16532                            else
16533                             if (pagination) {
16534                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16535                            }
16536    
16537                            String sql = query.toString();
16538    
16539                            Session session = null;
16540    
16541                            try {
16542                                    session = openSession();
16543    
16544                                    Query q = session.createQuery(sql);
16545    
16546                                    QueryPos qPos = QueryPos.getInstance(q);
16547    
16548                                    qPos.add(companyId);
16549    
16550                                    qPos.add(status);
16551    
16552                                    if (!pagination) {
16553                                            list = (List<JournalArticle>)QueryUtil.list(q,
16554                                                            getDialect(), start, end, false);
16555    
16556                                            Collections.sort(list);
16557    
16558                                            list = new UnmodifiableList<JournalArticle>(list);
16559                                    }
16560                                    else {
16561                                            list = (List<JournalArticle>)QueryUtil.list(q,
16562                                                            getDialect(), start, end);
16563                                    }
16564    
16565                                    cacheResult(list);
16566    
16567                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16568                            }
16569                            catch (Exception e) {
16570                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16571    
16572                                    throw processException(e);
16573                            }
16574                            finally {
16575                                    closeSession(session);
16576                            }
16577                    }
16578    
16579                    return list;
16580            }
16581    
16582            /**
16583             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16584             *
16585             * @param companyId the company ID
16586             * @param status the status
16587             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16588             * @return the first matching journal article
16589             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16590             * @throws SystemException if a system exception occurred
16591             */
16592            @Override
16593            public JournalArticle findByC_NotST_First(long companyId, int status,
16594                    OrderByComparator orderByComparator)
16595                    throws NoSuchArticleException, SystemException {
16596                    JournalArticle journalArticle = fetchByC_NotST_First(companyId, status,
16597                                    orderByComparator);
16598    
16599                    if (journalArticle != null) {
16600                            return journalArticle;
16601                    }
16602    
16603                    StringBundler msg = new StringBundler(6);
16604    
16605                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16606    
16607                    msg.append("companyId=");
16608                    msg.append(companyId);
16609    
16610                    msg.append(", status=");
16611                    msg.append(status);
16612    
16613                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16614    
16615                    throw new NoSuchArticleException(msg.toString());
16616            }
16617    
16618            /**
16619             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16620             *
16621             * @param companyId the company ID
16622             * @param status the status
16623             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16624             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16625             * @throws SystemException if a system exception occurred
16626             */
16627            @Override
16628            public JournalArticle fetchByC_NotST_First(long companyId, int status,
16629                    OrderByComparator orderByComparator) throws SystemException {
16630                    List<JournalArticle> list = findByC_NotST(companyId, status, 0, 1,
16631                                    orderByComparator);
16632    
16633                    if (!list.isEmpty()) {
16634                            return list.get(0);
16635                    }
16636    
16637                    return null;
16638            }
16639    
16640            /**
16641             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16642             *
16643             * @param companyId the company ID
16644             * @param status the status
16645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16646             * @return the last matching journal article
16647             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16648             * @throws SystemException if a system exception occurred
16649             */
16650            @Override
16651            public JournalArticle findByC_NotST_Last(long companyId, int status,
16652                    OrderByComparator orderByComparator)
16653                    throws NoSuchArticleException, SystemException {
16654                    JournalArticle journalArticle = fetchByC_NotST_Last(companyId, status,
16655                                    orderByComparator);
16656    
16657                    if (journalArticle != null) {
16658                            return journalArticle;
16659                    }
16660    
16661                    StringBundler msg = new StringBundler(6);
16662    
16663                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16664    
16665                    msg.append("companyId=");
16666                    msg.append(companyId);
16667    
16668                    msg.append(", status=");
16669                    msg.append(status);
16670    
16671                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16672    
16673                    throw new NoSuchArticleException(msg.toString());
16674            }
16675    
16676            /**
16677             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16678             *
16679             * @param companyId the company ID
16680             * @param status the status
16681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16682             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16683             * @throws SystemException if a system exception occurred
16684             */
16685            @Override
16686            public JournalArticle fetchByC_NotST_Last(long companyId, int status,
16687                    OrderByComparator orderByComparator) throws SystemException {
16688                    int count = countByC_NotST(companyId, status);
16689    
16690                    if (count == 0) {
16691                            return null;
16692                    }
16693    
16694                    List<JournalArticle> list = findByC_NotST(companyId, status, count - 1,
16695                                    count, orderByComparator);
16696    
16697                    if (!list.isEmpty()) {
16698                            return list.get(0);
16699                    }
16700    
16701                    return null;
16702            }
16703    
16704            /**
16705             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16706             *
16707             * @param id the primary key of the current journal article
16708             * @param companyId the company ID
16709             * @param status the status
16710             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16711             * @return the previous, current, and next journal article
16712             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16713             * @throws SystemException if a system exception occurred
16714             */
16715            @Override
16716            public JournalArticle[] findByC_NotST_PrevAndNext(long id, long companyId,
16717                    int status, OrderByComparator orderByComparator)
16718                    throws NoSuchArticleException, SystemException {
16719                    JournalArticle journalArticle = findByPrimaryKey(id);
16720    
16721                    Session session = null;
16722    
16723                    try {
16724                            session = openSession();
16725    
16726                            JournalArticle[] array = new JournalArticleImpl[3];
16727    
16728                            array[0] = getByC_NotST_PrevAndNext(session, journalArticle,
16729                                            companyId, status, orderByComparator, true);
16730    
16731                            array[1] = journalArticle;
16732    
16733                            array[2] = getByC_NotST_PrevAndNext(session, journalArticle,
16734                                            companyId, status, orderByComparator, false);
16735    
16736                            return array;
16737                    }
16738                    catch (Exception e) {
16739                            throw processException(e);
16740                    }
16741                    finally {
16742                            closeSession(session);
16743                    }
16744            }
16745    
16746            protected JournalArticle getByC_NotST_PrevAndNext(Session session,
16747                    JournalArticle journalArticle, long companyId, int status,
16748                    OrderByComparator orderByComparator, boolean previous) {
16749                    StringBundler query = null;
16750    
16751                    if (orderByComparator != null) {
16752                            query = new StringBundler(6 +
16753                                            (orderByComparator.getOrderByFields().length * 6));
16754                    }
16755                    else {
16756                            query = new StringBundler(3);
16757                    }
16758    
16759                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16760    
16761                    query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16762    
16763                    query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16764    
16765                    if (orderByComparator != null) {
16766                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16767    
16768                            if (orderByConditionFields.length > 0) {
16769                                    query.append(WHERE_AND);
16770                            }
16771    
16772                            for (int i = 0; i < orderByConditionFields.length; i++) {
16773                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16774                                    query.append(orderByConditionFields[i]);
16775    
16776                                    if ((i + 1) < orderByConditionFields.length) {
16777                                            if (orderByComparator.isAscending() ^ previous) {
16778                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16779                                            }
16780                                            else {
16781                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16782                                            }
16783                                    }
16784                                    else {
16785                                            if (orderByComparator.isAscending() ^ previous) {
16786                                                    query.append(WHERE_GREATER_THAN);
16787                                            }
16788                                            else {
16789                                                    query.append(WHERE_LESSER_THAN);
16790                                            }
16791                                    }
16792                            }
16793    
16794                            query.append(ORDER_BY_CLAUSE);
16795    
16796                            String[] orderByFields = orderByComparator.getOrderByFields();
16797    
16798                            for (int i = 0; i < orderByFields.length; i++) {
16799                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16800                                    query.append(orderByFields[i]);
16801    
16802                                    if ((i + 1) < orderByFields.length) {
16803                                            if (orderByComparator.isAscending() ^ previous) {
16804                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16805                                            }
16806                                            else {
16807                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16808                                            }
16809                                    }
16810                                    else {
16811                                            if (orderByComparator.isAscending() ^ previous) {
16812                                                    query.append(ORDER_BY_ASC);
16813                                            }
16814                                            else {
16815                                                    query.append(ORDER_BY_DESC);
16816                                            }
16817                                    }
16818                            }
16819                    }
16820                    else {
16821                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16822                    }
16823    
16824                    String sql = query.toString();
16825    
16826                    Query q = session.createQuery(sql);
16827    
16828                    q.setFirstResult(0);
16829                    q.setMaxResults(2);
16830    
16831                    QueryPos qPos = QueryPos.getInstance(q);
16832    
16833                    qPos.add(companyId);
16834    
16835                    qPos.add(status);
16836    
16837                    if (orderByComparator != null) {
16838                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16839    
16840                            for (Object value : values) {
16841                                    qPos.add(value);
16842                            }
16843                    }
16844    
16845                    List<JournalArticle> list = q.list();
16846    
16847                    if (list.size() == 2) {
16848                            return list.get(1);
16849                    }
16850                    else {
16851                            return null;
16852                    }
16853            }
16854    
16855            /**
16856             * Removes all the journal articles where companyId = &#63; and status &ne; &#63; from the database.
16857             *
16858             * @param companyId the company ID
16859             * @param status the status
16860             * @throws SystemException if a system exception occurred
16861             */
16862            @Override
16863            public void removeByC_NotST(long companyId, int status)
16864                    throws SystemException {
16865                    for (JournalArticle journalArticle : findByC_NotST(companyId, status,
16866                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16867                            remove(journalArticle);
16868                    }
16869            }
16870    
16871            /**
16872             * Returns the number of journal articles where companyId = &#63; and status &ne; &#63;.
16873             *
16874             * @param companyId the company ID
16875             * @param status the status
16876             * @return the number of matching journal articles
16877             * @throws SystemException if a system exception occurred
16878             */
16879            @Override
16880            public int countByC_NotST(long companyId, int status)
16881                    throws SystemException {
16882                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST;
16883    
16884                    Object[] finderArgs = new Object[] { companyId, status };
16885    
16886                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16887                                    this);
16888    
16889                    if (count == null) {
16890                            StringBundler query = new StringBundler(3);
16891    
16892                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16893    
16894                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16895    
16896                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16897    
16898                            String sql = query.toString();
16899    
16900                            Session session = null;
16901    
16902                            try {
16903                                    session = openSession();
16904    
16905                                    Query q = session.createQuery(sql);
16906    
16907                                    QueryPos qPos = QueryPos.getInstance(q);
16908    
16909                                    qPos.add(companyId);
16910    
16911                                    qPos.add(status);
16912    
16913                                    count = (Long)q.uniqueResult();
16914    
16915                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16916                            }
16917                            catch (Exception e) {
16918                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16919    
16920                                    throw processException(e);
16921                            }
16922                            finally {
16923                                    closeSession(session);
16924                            }
16925                    }
16926    
16927                    return count.intValue();
16928            }
16929    
16930            private static final String _FINDER_COLUMN_C_NOTST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16931            private static final String _FINDER_COLUMN_C_NOTST_STATUS_2 = "journalArticle.status != ?";
16932            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16933                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16934                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16935                            "findByC_T",
16936                            new String[] {
16937                                    Long.class.getName(), String.class.getName(),
16938                                    
16939                            Integer.class.getName(), Integer.class.getName(),
16940                                    OrderByComparator.class.getName()
16941                            });
16942            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16943                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16944                            JournalArticleImpl.class,
16945                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T",
16946                            new String[] { Long.class.getName(), String.class.getName() },
16947                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
16948                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
16949                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16950                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16951            public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16952                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16953                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T",
16954                            new String[] { Long.class.getName(), String.class.getName() });
16955    
16956            /**
16957             * Returns all the journal articles where classNameId = &#63; and templateId = &#63;.
16958             *
16959             * @param classNameId the class name ID
16960             * @param templateId the template ID
16961             * @return the matching journal articles
16962             * @throws SystemException if a system exception occurred
16963             */
16964            @Override
16965            public List<JournalArticle> findByC_T(long classNameId, String templateId)
16966                    throws SystemException {
16967                    return findByC_T(classNameId, templateId, QueryUtil.ALL_POS,
16968                            QueryUtil.ALL_POS, null);
16969            }
16970    
16971            /**
16972             * Returns a range of all the journal articles where classNameId = &#63; and templateId = &#63;.
16973             *
16974             * <p>
16975             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16976             * </p>
16977             *
16978             * @param classNameId the class name ID
16979             * @param templateId the template ID
16980             * @param start the lower bound of the range of journal articles
16981             * @param end the upper bound of the range of journal articles (not inclusive)
16982             * @return the range of matching journal articles
16983             * @throws SystemException if a system exception occurred
16984             */
16985            @Override
16986            public List<JournalArticle> findByC_T(long classNameId, String templateId,
16987                    int start, int end) throws SystemException {
16988                    return findByC_T(classNameId, templateId, start, end, null);
16989            }
16990    
16991            /**
16992             * Returns an ordered range of all the journal articles where classNameId = &#63; and templateId = &#63;.
16993             *
16994             * <p>
16995             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16996             * </p>
16997             *
16998             * @param classNameId the class name ID
16999             * @param templateId the template ID
17000             * @param start the lower bound of the range of journal articles
17001             * @param end the upper bound of the range of journal articles (not inclusive)
17002             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17003             * @return the ordered range of matching journal articles
17004             * @throws SystemException if a system exception occurred
17005             */
17006            @Override
17007            public List<JournalArticle> findByC_T(long classNameId, String templateId,
17008                    int start, int end, OrderByComparator orderByComparator)
17009                    throws SystemException {
17010                    boolean pagination = true;
17011                    FinderPath finderPath = null;
17012                    Object[] finderArgs = null;
17013    
17014                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17015                                    (orderByComparator == null)) {
17016                            pagination = false;
17017                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T;
17018                            finderArgs = new Object[] { classNameId, templateId };
17019                    }
17020                    else {
17021                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T;
17022                            finderArgs = new Object[] {
17023                                            classNameId, templateId,
17024                                            
17025                                            start, end, orderByComparator
17026                                    };
17027                    }
17028    
17029                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17030                                    finderArgs, this);
17031    
17032                    if ((list != null) && !list.isEmpty()) {
17033                            for (JournalArticle journalArticle : list) {
17034                                    if ((classNameId != journalArticle.getClassNameId()) ||
17035                                                    !Validator.equals(templateId,
17036                                                            journalArticle.getTemplateId())) {
17037                                            list = null;
17038    
17039                                            break;
17040                                    }
17041                            }
17042                    }
17043    
17044                    if (list == null) {
17045                            StringBundler query = null;
17046    
17047                            if (orderByComparator != null) {
17048                                    query = new StringBundler(4 +
17049                                                    (orderByComparator.getOrderByFields().length * 3));
17050                            }
17051                            else {
17052                                    query = new StringBundler(4);
17053                            }
17054    
17055                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17056    
17057                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
17058    
17059                            boolean bindTemplateId = false;
17060    
17061                            if (templateId == null) {
17062                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
17063                            }
17064                            else if (templateId.equals(StringPool.BLANK)) {
17065                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
17066                            }
17067                            else {
17068                                    bindTemplateId = true;
17069    
17070                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
17071                            }
17072    
17073                            if (orderByComparator != null) {
17074                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17075                                            orderByComparator);
17076                            }
17077                            else
17078                             if (pagination) {
17079                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17080                            }
17081    
17082                            String sql = query.toString();
17083    
17084                            Session session = null;
17085    
17086                            try {
17087                                    session = openSession();
17088    
17089                                    Query q = session.createQuery(sql);
17090    
17091                                    QueryPos qPos = QueryPos.getInstance(q);
17092    
17093                                    qPos.add(classNameId);
17094    
17095                                    if (bindTemplateId) {
17096                                            qPos.add(templateId);
17097                                    }
17098    
17099                                    if (!pagination) {
17100                                            list = (List<JournalArticle>)QueryUtil.list(q,
17101                                                            getDialect(), start, end, false);
17102    
17103                                            Collections.sort(list);
17104    
17105                                            list = new UnmodifiableList<JournalArticle>(list);
17106                                    }
17107                                    else {
17108                                            list = (List<JournalArticle>)QueryUtil.list(q,
17109                                                            getDialect(), start, end);
17110                                    }
17111    
17112                                    cacheResult(list);
17113    
17114                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17115                            }
17116                            catch (Exception e) {
17117                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17118    
17119                                    throw processException(e);
17120                            }
17121                            finally {
17122                                    closeSession(session);
17123                            }
17124                    }
17125    
17126                    return list;
17127            }
17128    
17129            /**
17130             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17131             *
17132             * @param classNameId the class name ID
17133             * @param templateId the template ID
17134             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17135             * @return the first matching journal article
17136             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17137             * @throws SystemException if a system exception occurred
17138             */
17139            @Override
17140            public JournalArticle findByC_T_First(long classNameId, String templateId,
17141                    OrderByComparator orderByComparator)
17142                    throws NoSuchArticleException, SystemException {
17143                    JournalArticle journalArticle = fetchByC_T_First(classNameId,
17144                                    templateId, orderByComparator);
17145    
17146                    if (journalArticle != null) {
17147                            return journalArticle;
17148                    }
17149    
17150                    StringBundler msg = new StringBundler(6);
17151    
17152                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17153    
17154                    msg.append("classNameId=");
17155                    msg.append(classNameId);
17156    
17157                    msg.append(", templateId=");
17158                    msg.append(templateId);
17159    
17160                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17161    
17162                    throw new NoSuchArticleException(msg.toString());
17163            }
17164    
17165            /**
17166             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17167             *
17168             * @param classNameId the class name ID
17169             * @param templateId the template ID
17170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17171             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17172             * @throws SystemException if a system exception occurred
17173             */
17174            @Override
17175            public JournalArticle fetchByC_T_First(long classNameId, String templateId,
17176                    OrderByComparator orderByComparator) throws SystemException {
17177                    List<JournalArticle> list = findByC_T(classNameId, templateId, 0, 1,
17178                                    orderByComparator);
17179    
17180                    if (!list.isEmpty()) {
17181                            return list.get(0);
17182                    }
17183    
17184                    return null;
17185            }
17186    
17187            /**
17188             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17189             *
17190             * @param classNameId the class name ID
17191             * @param templateId the template ID
17192             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17193             * @return the last matching journal article
17194             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17195             * @throws SystemException if a system exception occurred
17196             */
17197            @Override
17198            public JournalArticle findByC_T_Last(long classNameId, String templateId,
17199                    OrderByComparator orderByComparator)
17200                    throws NoSuchArticleException, SystemException {
17201                    JournalArticle journalArticle = fetchByC_T_Last(classNameId,
17202                                    templateId, orderByComparator);
17203    
17204                    if (journalArticle != null) {
17205                            return journalArticle;
17206                    }
17207    
17208                    StringBundler msg = new StringBundler(6);
17209    
17210                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17211    
17212                    msg.append("classNameId=");
17213                    msg.append(classNameId);
17214    
17215                    msg.append(", templateId=");
17216                    msg.append(templateId);
17217    
17218                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17219    
17220                    throw new NoSuchArticleException(msg.toString());
17221            }
17222    
17223            /**
17224             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17225             *
17226             * @param classNameId the class name ID
17227             * @param templateId the template ID
17228             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17229             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17230             * @throws SystemException if a system exception occurred
17231             */
17232            @Override
17233            public JournalArticle fetchByC_T_Last(long classNameId, String templateId,
17234                    OrderByComparator orderByComparator) throws SystemException {
17235                    int count = countByC_T(classNameId, templateId);
17236    
17237                    if (count == 0) {
17238                            return null;
17239                    }
17240    
17241                    List<JournalArticle> list = findByC_T(classNameId, templateId,
17242                                    count - 1, count, orderByComparator);
17243    
17244                    if (!list.isEmpty()) {
17245                            return list.get(0);
17246                    }
17247    
17248                    return null;
17249            }
17250    
17251            /**
17252             * Returns the journal articles before and after the current journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17253             *
17254             * @param id the primary key of the current journal article
17255             * @param classNameId the class name ID
17256             * @param templateId the template ID
17257             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17258             * @return the previous, current, and next journal article
17259             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17260             * @throws SystemException if a system exception occurred
17261             */
17262            @Override
17263            public JournalArticle[] findByC_T_PrevAndNext(long id, long classNameId,
17264                    String templateId, OrderByComparator orderByComparator)
17265                    throws NoSuchArticleException, SystemException {
17266                    JournalArticle journalArticle = findByPrimaryKey(id);
17267    
17268                    Session session = null;
17269    
17270                    try {
17271                            session = openSession();
17272    
17273                            JournalArticle[] array = new JournalArticleImpl[3];
17274    
17275                            array[0] = getByC_T_PrevAndNext(session, journalArticle,
17276                                            classNameId, templateId, orderByComparator, true);
17277    
17278                            array[1] = journalArticle;
17279    
17280                            array[2] = getByC_T_PrevAndNext(session, journalArticle,
17281                                            classNameId, templateId, orderByComparator, false);
17282    
17283                            return array;
17284                    }
17285                    catch (Exception e) {
17286                            throw processException(e);
17287                    }
17288                    finally {
17289                            closeSession(session);
17290                    }
17291            }
17292    
17293            protected JournalArticle getByC_T_PrevAndNext(Session session,
17294                    JournalArticle journalArticle, long classNameId, String templateId,
17295                    OrderByComparator orderByComparator, boolean previous) {
17296                    StringBundler query = null;
17297    
17298                    if (orderByComparator != null) {
17299                            query = new StringBundler(6 +
17300                                            (orderByComparator.getOrderByFields().length * 6));
17301                    }
17302                    else {
17303                            query = new StringBundler(3);
17304                    }
17305    
17306                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17307    
17308                    query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
17309    
17310                    boolean bindTemplateId = false;
17311    
17312                    if (templateId == null) {
17313                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
17314                    }
17315                    else if (templateId.equals(StringPool.BLANK)) {
17316                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
17317                    }
17318                    else {
17319                            bindTemplateId = true;
17320    
17321                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
17322                    }
17323    
17324                    if (orderByComparator != null) {
17325                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17326    
17327                            if (orderByConditionFields.length > 0) {
17328                                    query.append(WHERE_AND);
17329                            }
17330    
17331                            for (int i = 0; i < orderByConditionFields.length; i++) {
17332                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17333                                    query.append(orderByConditionFields[i]);
17334    
17335                                    if ((i + 1) < orderByConditionFields.length) {
17336                                            if (orderByComparator.isAscending() ^ previous) {
17337                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17338                                            }
17339                                            else {
17340                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17341                                            }
17342                                    }
17343                                    else {
17344                                            if (orderByComparator.isAscending() ^ previous) {
17345                                                    query.append(WHERE_GREATER_THAN);
17346                                            }
17347                                            else {
17348                                                    query.append(WHERE_LESSER_THAN);
17349                                            }
17350                                    }
17351                            }
17352    
17353                            query.append(ORDER_BY_CLAUSE);
17354    
17355                            String[] orderByFields = orderByComparator.getOrderByFields();
17356    
17357                            for (int i = 0; i < orderByFields.length; i++) {
17358                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17359                                    query.append(orderByFields[i]);
17360    
17361                                    if ((i + 1) < orderByFields.length) {
17362                                            if (orderByComparator.isAscending() ^ previous) {
17363                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17364                                            }
17365                                            else {
17366                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17367                                            }
17368                                    }
17369                                    else {
17370                                            if (orderByComparator.isAscending() ^ previous) {
17371                                                    query.append(ORDER_BY_ASC);
17372                                            }
17373                                            else {
17374                                                    query.append(ORDER_BY_DESC);
17375                                            }
17376                                    }
17377                            }
17378                    }
17379                    else {
17380                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17381                    }
17382    
17383                    String sql = query.toString();
17384    
17385                    Query q = session.createQuery(sql);
17386    
17387                    q.setFirstResult(0);
17388                    q.setMaxResults(2);
17389    
17390                    QueryPos qPos = QueryPos.getInstance(q);
17391    
17392                    qPos.add(classNameId);
17393    
17394                    if (bindTemplateId) {
17395                            qPos.add(templateId);
17396                    }
17397    
17398                    if (orderByComparator != null) {
17399                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17400    
17401                            for (Object value : values) {
17402                                    qPos.add(value);
17403                            }
17404                    }
17405    
17406                    List<JournalArticle> list = q.list();
17407    
17408                    if (list.size() == 2) {
17409                            return list.get(1);
17410                    }
17411                    else {
17412                            return null;
17413                    }
17414            }
17415    
17416            /**
17417             * Removes all the journal articles where classNameId = &#63; and templateId = &#63; from the database.
17418             *
17419             * @param classNameId the class name ID
17420             * @param templateId the template ID
17421             * @throws SystemException if a system exception occurred
17422             */
17423            @Override
17424            public void removeByC_T(long classNameId, String templateId)
17425                    throws SystemException {
17426                    for (JournalArticle journalArticle : findByC_T(classNameId, templateId,
17427                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17428                            remove(journalArticle);
17429                    }
17430            }
17431    
17432            /**
17433             * Returns the number of journal articles where classNameId = &#63; and templateId = &#63;.
17434             *
17435             * @param classNameId the class name ID
17436             * @param templateId the template ID
17437             * @return the number of matching journal articles
17438             * @throws SystemException if a system exception occurred
17439             */
17440            @Override
17441            public int countByC_T(long classNameId, String templateId)
17442                    throws SystemException {
17443                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_T;
17444    
17445                    Object[] finderArgs = new Object[] { classNameId, templateId };
17446    
17447                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17448                                    this);
17449    
17450                    if (count == null) {
17451                            StringBundler query = new StringBundler(3);
17452    
17453                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17454    
17455                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
17456    
17457                            boolean bindTemplateId = false;
17458    
17459                            if (templateId == null) {
17460                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
17461                            }
17462                            else if (templateId.equals(StringPool.BLANK)) {
17463                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
17464                            }
17465                            else {
17466                                    bindTemplateId = true;
17467    
17468                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
17469                            }
17470    
17471                            String sql = query.toString();
17472    
17473                            Session session = null;
17474    
17475                            try {
17476                                    session = openSession();
17477    
17478                                    Query q = session.createQuery(sql);
17479    
17480                                    QueryPos qPos = QueryPos.getInstance(q);
17481    
17482                                    qPos.add(classNameId);
17483    
17484                                    if (bindTemplateId) {
17485                                            qPos.add(templateId);
17486                                    }
17487    
17488                                    count = (Long)q.uniqueResult();
17489    
17490                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17491                            }
17492                            catch (Exception e) {
17493                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17494    
17495                                    throw processException(e);
17496                            }
17497                            finally {
17498                                    closeSession(session);
17499                            }
17500                    }
17501    
17502                    return count.intValue();
17503            }
17504    
17505            private static final String _FINDER_COLUMN_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17506            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
17507            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
17508            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
17509            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17510                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17511                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17512                            "findByLtD_S",
17513                            new String[] {
17514                                    Date.class.getName(), Integer.class.getName(),
17515                                    
17516                            Integer.class.getName(), Integer.class.getName(),
17517                                    OrderByComparator.class.getName()
17518                            });
17519            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17520                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17521                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
17522                            new String[] { Date.class.getName(), Integer.class.getName() });
17523    
17524            /**
17525             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
17526             *
17527             * @param displayDate the display date
17528             * @param status the status
17529             * @return the matching journal articles
17530             * @throws SystemException if a system exception occurred
17531             */
17532            @Override
17533            public List<JournalArticle> findByLtD_S(Date displayDate, int status)
17534                    throws SystemException {
17535                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
17536                            QueryUtil.ALL_POS, null);
17537            }
17538    
17539            /**
17540             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17541             *
17542             * <p>
17543             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17544             * </p>
17545             *
17546             * @param displayDate the display date
17547             * @param status the status
17548             * @param start the lower bound of the range of journal articles
17549             * @param end the upper bound of the range of journal articles (not inclusive)
17550             * @return the range of matching journal articles
17551             * @throws SystemException if a system exception occurred
17552             */
17553            @Override
17554            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17555                    int start, int end) throws SystemException {
17556                    return findByLtD_S(displayDate, status, start, end, null);
17557            }
17558    
17559            /**
17560             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17561             *
17562             * <p>
17563             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17564             * </p>
17565             *
17566             * @param displayDate the display date
17567             * @param status the status
17568             * @param start the lower bound of the range of journal articles
17569             * @param end the upper bound of the range of journal articles (not inclusive)
17570             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17571             * @return the ordered range of matching journal articles
17572             * @throws SystemException if a system exception occurred
17573             */
17574            @Override
17575            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17576                    int start, int end, OrderByComparator orderByComparator)
17577                    throws SystemException {
17578                    boolean pagination = true;
17579                    FinderPath finderPath = null;
17580                    Object[] finderArgs = null;
17581    
17582                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
17583                    finderArgs = new Object[] {
17584                                    displayDate, status,
17585                                    
17586                                    start, end, orderByComparator
17587                            };
17588    
17589                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17590                                    finderArgs, this);
17591    
17592                    if ((list != null) && !list.isEmpty()) {
17593                            for (JournalArticle journalArticle : list) {
17594                                    if ((displayDate.getTime() <= journalArticle.getDisplayDate()
17595                                                                                                                                    .getTime()) ||
17596                                                    (status != journalArticle.getStatus())) {
17597                                            list = null;
17598    
17599                                            break;
17600                                    }
17601                            }
17602                    }
17603    
17604                    if (list == null) {
17605                            StringBundler query = null;
17606    
17607                            if (orderByComparator != null) {
17608                                    query = new StringBundler(4 +
17609                                                    (orderByComparator.getOrderByFields().length * 3));
17610                            }
17611                            else {
17612                                    query = new StringBundler(4);
17613                            }
17614    
17615                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17616    
17617                            boolean bindDisplayDate = false;
17618    
17619                            if (displayDate == null) {
17620                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17621                            }
17622                            else {
17623                                    bindDisplayDate = true;
17624    
17625                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17626                            }
17627    
17628                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17629    
17630                            if (orderByComparator != null) {
17631                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17632                                            orderByComparator);
17633                            }
17634                            else
17635                             if (pagination) {
17636                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17637                            }
17638    
17639                            String sql = query.toString();
17640    
17641                            Session session = null;
17642    
17643                            try {
17644                                    session = openSession();
17645    
17646                                    Query q = session.createQuery(sql);
17647    
17648                                    QueryPos qPos = QueryPos.getInstance(q);
17649    
17650                                    if (bindDisplayDate) {
17651                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17652                                    }
17653    
17654                                    qPos.add(status);
17655    
17656                                    if (!pagination) {
17657                                            list = (List<JournalArticle>)QueryUtil.list(q,
17658                                                            getDialect(), start, end, false);
17659    
17660                                            Collections.sort(list);
17661    
17662                                            list = new UnmodifiableList<JournalArticle>(list);
17663                                    }
17664                                    else {
17665                                            list = (List<JournalArticle>)QueryUtil.list(q,
17666                                                            getDialect(), start, end);
17667                                    }
17668    
17669                                    cacheResult(list);
17670    
17671                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17672                            }
17673                            catch (Exception e) {
17674                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17675    
17676                                    throw processException(e);
17677                            }
17678                            finally {
17679                                    closeSession(session);
17680                            }
17681                    }
17682    
17683                    return list;
17684            }
17685    
17686            /**
17687             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17688             *
17689             * @param displayDate the display date
17690             * @param status the status
17691             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17692             * @return the first matching journal article
17693             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17694             * @throws SystemException if a system exception occurred
17695             */
17696            @Override
17697            public JournalArticle findByLtD_S_First(Date displayDate, int status,
17698                    OrderByComparator orderByComparator)
17699                    throws NoSuchArticleException, SystemException {
17700                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
17701                                    orderByComparator);
17702    
17703                    if (journalArticle != null) {
17704                            return journalArticle;
17705                    }
17706    
17707                    StringBundler msg = new StringBundler(6);
17708    
17709                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17710    
17711                    msg.append("displayDate=");
17712                    msg.append(displayDate);
17713    
17714                    msg.append(", status=");
17715                    msg.append(status);
17716    
17717                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17718    
17719                    throw new NoSuchArticleException(msg.toString());
17720            }
17721    
17722            /**
17723             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17724             *
17725             * @param displayDate the display date
17726             * @param status the status
17727             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17728             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17729             * @throws SystemException if a system exception occurred
17730             */
17731            @Override
17732            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
17733                    OrderByComparator orderByComparator) throws SystemException {
17734                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
17735                                    orderByComparator);
17736    
17737                    if (!list.isEmpty()) {
17738                            return list.get(0);
17739                    }
17740    
17741                    return null;
17742            }
17743    
17744            /**
17745             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17746             *
17747             * @param displayDate the display date
17748             * @param status the status
17749             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17750             * @return the last matching journal article
17751             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17752             * @throws SystemException if a system exception occurred
17753             */
17754            @Override
17755            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
17756                    OrderByComparator orderByComparator)
17757                    throws NoSuchArticleException, SystemException {
17758                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
17759                                    orderByComparator);
17760    
17761                    if (journalArticle != null) {
17762                            return journalArticle;
17763                    }
17764    
17765                    StringBundler msg = new StringBundler(6);
17766    
17767                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17768    
17769                    msg.append("displayDate=");
17770                    msg.append(displayDate);
17771    
17772                    msg.append(", status=");
17773                    msg.append(status);
17774    
17775                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17776    
17777                    throw new NoSuchArticleException(msg.toString());
17778            }
17779    
17780            /**
17781             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17782             *
17783             * @param displayDate the display date
17784             * @param status the status
17785             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17786             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17787             * @throws SystemException if a system exception occurred
17788             */
17789            @Override
17790            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
17791                    OrderByComparator orderByComparator) throws SystemException {
17792                    int count = countByLtD_S(displayDate, status);
17793    
17794                    if (count == 0) {
17795                            return null;
17796                    }
17797    
17798                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
17799                                    count, orderByComparator);
17800    
17801                    if (!list.isEmpty()) {
17802                            return list.get(0);
17803                    }
17804    
17805                    return null;
17806            }
17807    
17808            /**
17809             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17810             *
17811             * @param id the primary key of the current journal article
17812             * @param displayDate the display date
17813             * @param status the status
17814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17815             * @return the previous, current, and next journal article
17816             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17817             * @throws SystemException if a system exception occurred
17818             */
17819            @Override
17820            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
17821                    int status, OrderByComparator orderByComparator)
17822                    throws NoSuchArticleException, SystemException {
17823                    JournalArticle journalArticle = findByPrimaryKey(id);
17824    
17825                    Session session = null;
17826    
17827                    try {
17828                            session = openSession();
17829    
17830                            JournalArticle[] array = new JournalArticleImpl[3];
17831    
17832                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
17833                                            displayDate, status, orderByComparator, true);
17834    
17835                            array[1] = journalArticle;
17836    
17837                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
17838                                            displayDate, status, orderByComparator, false);
17839    
17840                            return array;
17841                    }
17842                    catch (Exception e) {
17843                            throw processException(e);
17844                    }
17845                    finally {
17846                            closeSession(session);
17847                    }
17848            }
17849    
17850            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
17851                    JournalArticle journalArticle, Date displayDate, int status,
17852                    OrderByComparator orderByComparator, boolean previous) {
17853                    StringBundler query = null;
17854    
17855                    if (orderByComparator != null) {
17856                            query = new StringBundler(6 +
17857                                            (orderByComparator.getOrderByFields().length * 6));
17858                    }
17859                    else {
17860                            query = new StringBundler(3);
17861                    }
17862    
17863                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17864    
17865                    boolean bindDisplayDate = false;
17866    
17867                    if (displayDate == null) {
17868                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17869                    }
17870                    else {
17871                            bindDisplayDate = true;
17872    
17873                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17874                    }
17875    
17876                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17877    
17878                    if (orderByComparator != null) {
17879                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17880    
17881                            if (orderByConditionFields.length > 0) {
17882                                    query.append(WHERE_AND);
17883                            }
17884    
17885                            for (int i = 0; i < orderByConditionFields.length; i++) {
17886                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17887                                    query.append(orderByConditionFields[i]);
17888    
17889                                    if ((i + 1) < orderByConditionFields.length) {
17890                                            if (orderByComparator.isAscending() ^ previous) {
17891                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17892                                            }
17893                                            else {
17894                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17895                                            }
17896                                    }
17897                                    else {
17898                                            if (orderByComparator.isAscending() ^ previous) {
17899                                                    query.append(WHERE_GREATER_THAN);
17900                                            }
17901                                            else {
17902                                                    query.append(WHERE_LESSER_THAN);
17903                                            }
17904                                    }
17905                            }
17906    
17907                            query.append(ORDER_BY_CLAUSE);
17908    
17909                            String[] orderByFields = orderByComparator.getOrderByFields();
17910    
17911                            for (int i = 0; i < orderByFields.length; i++) {
17912                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17913                                    query.append(orderByFields[i]);
17914    
17915                                    if ((i + 1) < orderByFields.length) {
17916                                            if (orderByComparator.isAscending() ^ previous) {
17917                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17918                                            }
17919                                            else {
17920                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17921                                            }
17922                                    }
17923                                    else {
17924                                            if (orderByComparator.isAscending() ^ previous) {
17925                                                    query.append(ORDER_BY_ASC);
17926                                            }
17927                                            else {
17928                                                    query.append(ORDER_BY_DESC);
17929                                            }
17930                                    }
17931                            }
17932                    }
17933                    else {
17934                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17935                    }
17936    
17937                    String sql = query.toString();
17938    
17939                    Query q = session.createQuery(sql);
17940    
17941                    q.setFirstResult(0);
17942                    q.setMaxResults(2);
17943    
17944                    QueryPos qPos = QueryPos.getInstance(q);
17945    
17946                    if (bindDisplayDate) {
17947                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17948                    }
17949    
17950                    qPos.add(status);
17951    
17952                    if (orderByComparator != null) {
17953                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17954    
17955                            for (Object value : values) {
17956                                    qPos.add(value);
17957                            }
17958                    }
17959    
17960                    List<JournalArticle> list = q.list();
17961    
17962                    if (list.size() == 2) {
17963                            return list.get(1);
17964                    }
17965                    else {
17966                            return null;
17967                    }
17968            }
17969    
17970            /**
17971             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
17972             *
17973             * @param displayDate the display date
17974             * @param status the status
17975             * @throws SystemException if a system exception occurred
17976             */
17977            @Override
17978            public void removeByLtD_S(Date displayDate, int status)
17979                    throws SystemException {
17980                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
17981                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17982                            remove(journalArticle);
17983                    }
17984            }
17985    
17986            /**
17987             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
17988             *
17989             * @param displayDate the display date
17990             * @param status the status
17991             * @return the number of matching journal articles
17992             * @throws SystemException if a system exception occurred
17993             */
17994            @Override
17995            public int countByLtD_S(Date displayDate, int status)
17996                    throws SystemException {
17997                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
17998    
17999                    Object[] finderArgs = new Object[] { displayDate, status };
18000    
18001                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18002                                    this);
18003    
18004                    if (count == null) {
18005                            StringBundler query = new StringBundler(3);
18006    
18007                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18008    
18009                            boolean bindDisplayDate = false;
18010    
18011                            if (displayDate == null) {
18012                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
18013                            }
18014                            else {
18015                                    bindDisplayDate = true;
18016    
18017                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
18018                            }
18019    
18020                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
18021    
18022                            String sql = query.toString();
18023    
18024                            Session session = null;
18025    
18026                            try {
18027                                    session = openSession();
18028    
18029                                    Query q = session.createQuery(sql);
18030    
18031                                    QueryPos qPos = QueryPos.getInstance(q);
18032    
18033                                    if (bindDisplayDate) {
18034                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
18035                                    }
18036    
18037                                    qPos.add(status);
18038    
18039                                    count = (Long)q.uniqueResult();
18040    
18041                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18042                            }
18043                            catch (Exception e) {
18044                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18045    
18046                                    throw processException(e);
18047                            }
18048                            finally {
18049                                    closeSession(session);
18050                            }
18051                    }
18052    
18053                    return count.intValue();
18054            }
18055    
18056            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
18057            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
18058            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
18059            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18060                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18061                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18062                            "findByR_I_S",
18063                            new String[] {
18064                                    Long.class.getName(), Boolean.class.getName(),
18065                                    Integer.class.getName(),
18066                                    
18067                            Integer.class.getName(), Integer.class.getName(),
18068                                    OrderByComparator.class.getName()
18069                            });
18070            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18071                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18072                            JournalArticleImpl.class,
18073                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
18074                            new String[] {
18075                                    Long.class.getName(), Boolean.class.getName(),
18076                                    Integer.class.getName()
18077                            },
18078                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
18079                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
18080                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
18081                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18082                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18083            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18084                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18085                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
18086                            new String[] {
18087                                    Long.class.getName(), Boolean.class.getName(),
18088                                    Integer.class.getName()
18089                            });
18090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18091                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18092                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
18093                            new String[] {
18094                                    Long.class.getName(), Boolean.class.getName(),
18095                                    Integer.class.getName()
18096                            });
18097    
18098            /**
18099             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18100             *
18101             * @param resourcePrimKey the resource prim key
18102             * @param indexable the indexable
18103             * @param status the status
18104             * @return the matching journal articles
18105             * @throws SystemException if a system exception occurred
18106             */
18107            @Override
18108            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18109                    boolean indexable, int status) throws SystemException {
18110                    return findByR_I_S(resourcePrimKey, indexable, status,
18111                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18112            }
18113    
18114            /**
18115             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18116             *
18117             * <p>
18118             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18119             * </p>
18120             *
18121             * @param resourcePrimKey the resource prim key
18122             * @param indexable the indexable
18123             * @param status the status
18124             * @param start the lower bound of the range of journal articles
18125             * @param end the upper bound of the range of journal articles (not inclusive)
18126             * @return the range of matching journal articles
18127             * @throws SystemException if a system exception occurred
18128             */
18129            @Override
18130            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18131                    boolean indexable, int status, int start, int end)
18132                    throws SystemException {
18133                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
18134            }
18135    
18136            /**
18137             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18138             *
18139             * <p>
18140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18141             * </p>
18142             *
18143             * @param resourcePrimKey the resource prim key
18144             * @param indexable the indexable
18145             * @param status the status
18146             * @param start the lower bound of the range of journal articles
18147             * @param end the upper bound of the range of journal articles (not inclusive)
18148             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18149             * @return the ordered range of matching journal articles
18150             * @throws SystemException if a system exception occurred
18151             */
18152            @Override
18153            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18154                    boolean indexable, int status, int start, int end,
18155                    OrderByComparator orderByComparator) throws SystemException {
18156                    boolean pagination = true;
18157                    FinderPath finderPath = null;
18158                    Object[] finderArgs = null;
18159    
18160                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18161                                    (orderByComparator == null)) {
18162                            pagination = false;
18163                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
18164                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
18165                    }
18166                    else {
18167                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
18168                            finderArgs = new Object[] {
18169                                            resourcePrimKey, indexable, status,
18170                                            
18171                                            start, end, orderByComparator
18172                                    };
18173                    }
18174    
18175                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18176                                    finderArgs, this);
18177    
18178                    if ((list != null) && !list.isEmpty()) {
18179                            for (JournalArticle journalArticle : list) {
18180                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
18181                                                    (indexable != journalArticle.getIndexable()) ||
18182                                                    (status != journalArticle.getStatus())) {
18183                                            list = null;
18184    
18185                                            break;
18186                                    }
18187                            }
18188                    }
18189    
18190                    if (list == null) {
18191                            StringBundler query = null;
18192    
18193                            if (orderByComparator != null) {
18194                                    query = new StringBundler(5 +
18195                                                    (orderByComparator.getOrderByFields().length * 3));
18196                            }
18197                            else {
18198                                    query = new StringBundler(5);
18199                            }
18200    
18201                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18202    
18203                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18204    
18205                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18206    
18207                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18208    
18209                            if (orderByComparator != null) {
18210                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18211                                            orderByComparator);
18212                            }
18213                            else
18214                             if (pagination) {
18215                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18216                            }
18217    
18218                            String sql = query.toString();
18219    
18220                            Session session = null;
18221    
18222                            try {
18223                                    session = openSession();
18224    
18225                                    Query q = session.createQuery(sql);
18226    
18227                                    QueryPos qPos = QueryPos.getInstance(q);
18228    
18229                                    qPos.add(resourcePrimKey);
18230    
18231                                    qPos.add(indexable);
18232    
18233                                    qPos.add(status);
18234    
18235                                    if (!pagination) {
18236                                            list = (List<JournalArticle>)QueryUtil.list(q,
18237                                                            getDialect(), start, end, false);
18238    
18239                                            Collections.sort(list);
18240    
18241                                            list = new UnmodifiableList<JournalArticle>(list);
18242                                    }
18243                                    else {
18244                                            list = (List<JournalArticle>)QueryUtil.list(q,
18245                                                            getDialect(), start, end);
18246                                    }
18247    
18248                                    cacheResult(list);
18249    
18250                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18251                            }
18252                            catch (Exception e) {
18253                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18254    
18255                                    throw processException(e);
18256                            }
18257                            finally {
18258                                    closeSession(session);
18259                            }
18260                    }
18261    
18262                    return list;
18263            }
18264    
18265            /**
18266             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18267             *
18268             * @param resourcePrimKey the resource prim key
18269             * @param indexable the indexable
18270             * @param status the status
18271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18272             * @return the first matching journal article
18273             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18274             * @throws SystemException if a system exception occurred
18275             */
18276            @Override
18277            public JournalArticle findByR_I_S_First(long resourcePrimKey,
18278                    boolean indexable, int status, OrderByComparator orderByComparator)
18279                    throws NoSuchArticleException, SystemException {
18280                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
18281                                    indexable, status, orderByComparator);
18282    
18283                    if (journalArticle != null) {
18284                            return journalArticle;
18285                    }
18286    
18287                    StringBundler msg = new StringBundler(8);
18288    
18289                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18290    
18291                    msg.append("resourcePrimKey=");
18292                    msg.append(resourcePrimKey);
18293    
18294                    msg.append(", indexable=");
18295                    msg.append(indexable);
18296    
18297                    msg.append(", status=");
18298                    msg.append(status);
18299    
18300                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18301    
18302                    throw new NoSuchArticleException(msg.toString());
18303            }
18304    
18305            /**
18306             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18307             *
18308             * @param resourcePrimKey the resource prim key
18309             * @param indexable the indexable
18310             * @param status the status
18311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18312             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18313             * @throws SystemException if a system exception occurred
18314             */
18315            @Override
18316            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
18317                    boolean indexable, int status, OrderByComparator orderByComparator)
18318                    throws SystemException {
18319                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
18320                                    status, 0, 1, orderByComparator);
18321    
18322                    if (!list.isEmpty()) {
18323                            return list.get(0);
18324                    }
18325    
18326                    return null;
18327            }
18328    
18329            /**
18330             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18331             *
18332             * @param resourcePrimKey the resource prim key
18333             * @param indexable the indexable
18334             * @param status the status
18335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18336             * @return the last matching journal article
18337             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18338             * @throws SystemException if a system exception occurred
18339             */
18340            @Override
18341            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
18342                    boolean indexable, int status, OrderByComparator orderByComparator)
18343                    throws NoSuchArticleException, SystemException {
18344                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
18345                                    indexable, status, orderByComparator);
18346    
18347                    if (journalArticle != null) {
18348                            return journalArticle;
18349                    }
18350    
18351                    StringBundler msg = new StringBundler(8);
18352    
18353                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18354    
18355                    msg.append("resourcePrimKey=");
18356                    msg.append(resourcePrimKey);
18357    
18358                    msg.append(", indexable=");
18359                    msg.append(indexable);
18360    
18361                    msg.append(", status=");
18362                    msg.append(status);
18363    
18364                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18365    
18366                    throw new NoSuchArticleException(msg.toString());
18367            }
18368    
18369            /**
18370             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18371             *
18372             * @param resourcePrimKey the resource prim key
18373             * @param indexable the indexable
18374             * @param status the status
18375             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18376             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18377             * @throws SystemException if a system exception occurred
18378             */
18379            @Override
18380            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
18381                    boolean indexable, int status, OrderByComparator orderByComparator)
18382                    throws SystemException {
18383                    int count = countByR_I_S(resourcePrimKey, indexable, status);
18384    
18385                    if (count == 0) {
18386                            return null;
18387                    }
18388    
18389                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
18390                                    status, count - 1, count, orderByComparator);
18391    
18392                    if (!list.isEmpty()) {
18393                            return list.get(0);
18394                    }
18395    
18396                    return null;
18397            }
18398    
18399            /**
18400             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18401             *
18402             * @param id the primary key of the current journal article
18403             * @param resourcePrimKey the resource prim key
18404             * @param indexable the indexable
18405             * @param status the status
18406             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18407             * @return the previous, current, and next journal article
18408             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18409             * @throws SystemException if a system exception occurred
18410             */
18411            @Override
18412            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
18413                    long resourcePrimKey, boolean indexable, int status,
18414                    OrderByComparator orderByComparator)
18415                    throws NoSuchArticleException, SystemException {
18416                    JournalArticle journalArticle = findByPrimaryKey(id);
18417    
18418                    Session session = null;
18419    
18420                    try {
18421                            session = openSession();
18422    
18423                            JournalArticle[] array = new JournalArticleImpl[3];
18424    
18425                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
18426                                            resourcePrimKey, indexable, status, orderByComparator, true);
18427    
18428                            array[1] = journalArticle;
18429    
18430                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
18431                                            resourcePrimKey, indexable, status, orderByComparator, false);
18432    
18433                            return array;
18434                    }
18435                    catch (Exception e) {
18436                            throw processException(e);
18437                    }
18438                    finally {
18439                            closeSession(session);
18440                    }
18441            }
18442    
18443            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
18444                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
18445                    int status, OrderByComparator orderByComparator, boolean previous) {
18446                    StringBundler query = null;
18447    
18448                    if (orderByComparator != null) {
18449                            query = new StringBundler(6 +
18450                                            (orderByComparator.getOrderByFields().length * 6));
18451                    }
18452                    else {
18453                            query = new StringBundler(3);
18454                    }
18455    
18456                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18457    
18458                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18459    
18460                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18461    
18462                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18463    
18464                    if (orderByComparator != null) {
18465                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18466    
18467                            if (orderByConditionFields.length > 0) {
18468                                    query.append(WHERE_AND);
18469                            }
18470    
18471                            for (int i = 0; i < orderByConditionFields.length; i++) {
18472                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18473                                    query.append(orderByConditionFields[i]);
18474    
18475                                    if ((i + 1) < orderByConditionFields.length) {
18476                                            if (orderByComparator.isAscending() ^ previous) {
18477                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18478                                            }
18479                                            else {
18480                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18481                                            }
18482                                    }
18483                                    else {
18484                                            if (orderByComparator.isAscending() ^ previous) {
18485                                                    query.append(WHERE_GREATER_THAN);
18486                                            }
18487                                            else {
18488                                                    query.append(WHERE_LESSER_THAN);
18489                                            }
18490                                    }
18491                            }
18492    
18493                            query.append(ORDER_BY_CLAUSE);
18494    
18495                            String[] orderByFields = orderByComparator.getOrderByFields();
18496    
18497                            for (int i = 0; i < orderByFields.length; i++) {
18498                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18499                                    query.append(orderByFields[i]);
18500    
18501                                    if ((i + 1) < orderByFields.length) {
18502                                            if (orderByComparator.isAscending() ^ previous) {
18503                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18504                                            }
18505                                            else {
18506                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18507                                            }
18508                                    }
18509                                    else {
18510                                            if (orderByComparator.isAscending() ^ previous) {
18511                                                    query.append(ORDER_BY_ASC);
18512                                            }
18513                                            else {
18514                                                    query.append(ORDER_BY_DESC);
18515                                            }
18516                                    }
18517                            }
18518                    }
18519                    else {
18520                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18521                    }
18522    
18523                    String sql = query.toString();
18524    
18525                    Query q = session.createQuery(sql);
18526    
18527                    q.setFirstResult(0);
18528                    q.setMaxResults(2);
18529    
18530                    QueryPos qPos = QueryPos.getInstance(q);
18531    
18532                    qPos.add(resourcePrimKey);
18533    
18534                    qPos.add(indexable);
18535    
18536                    qPos.add(status);
18537    
18538                    if (orderByComparator != null) {
18539                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18540    
18541                            for (Object value : values) {
18542                                    qPos.add(value);
18543                            }
18544                    }
18545    
18546                    List<JournalArticle> list = q.list();
18547    
18548                    if (list.size() == 2) {
18549                            return list.get(1);
18550                    }
18551                    else {
18552                            return null;
18553                    }
18554            }
18555    
18556            /**
18557             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18558             *
18559             * <p>
18560             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18561             * </p>
18562             *
18563             * @param resourcePrimKey the resource prim key
18564             * @param indexable the indexable
18565             * @param statuses the statuses
18566             * @return the matching journal articles
18567             * @throws SystemException if a system exception occurred
18568             */
18569            @Override
18570            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18571                    boolean indexable, int[] statuses) throws SystemException {
18572                    return findByR_I_S(resourcePrimKey, indexable, statuses,
18573                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18574            }
18575    
18576            /**
18577             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18578             *
18579             * <p>
18580             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18581             * </p>
18582             *
18583             * @param resourcePrimKey the resource prim key
18584             * @param indexable the indexable
18585             * @param statuses the statuses
18586             * @param start the lower bound of the range of journal articles
18587             * @param end the upper bound of the range of journal articles (not inclusive)
18588             * @return the range of matching journal articles
18589             * @throws SystemException if a system exception occurred
18590             */
18591            @Override
18592            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18593                    boolean indexable, int[] statuses, int start, int end)
18594                    throws SystemException {
18595                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
18596                            null);
18597            }
18598    
18599            /**
18600             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18601             *
18602             * <p>
18603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18604             * </p>
18605             *
18606             * @param resourcePrimKey the resource prim key
18607             * @param indexable the indexable
18608             * @param statuses the statuses
18609             * @param start the lower bound of the range of journal articles
18610             * @param end the upper bound of the range of journal articles (not inclusive)
18611             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18612             * @return the ordered range of matching journal articles
18613             * @throws SystemException if a system exception occurred
18614             */
18615            @Override
18616            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18617                    boolean indexable, int[] statuses, int start, int end,
18618                    OrderByComparator orderByComparator) throws SystemException {
18619                    if ((statuses != null) && (statuses.length == 1)) {
18620                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
18621                                    end, orderByComparator);
18622                    }
18623    
18624                    boolean pagination = true;
18625                    Object[] finderArgs = null;
18626    
18627                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18628                                    (orderByComparator == null)) {
18629                            pagination = false;
18630                            finderArgs = new Object[] {
18631                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
18632                                    };
18633                    }
18634                    else {
18635                            finderArgs = new Object[] {
18636                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
18637                                            
18638                                            start, end, orderByComparator
18639                                    };
18640                    }
18641    
18642                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18643                                    finderArgs, this);
18644    
18645                    if ((list != null) && !list.isEmpty()) {
18646                            for (JournalArticle journalArticle : list) {
18647                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
18648                                                    (indexable != journalArticle.getIndexable()) ||
18649                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
18650                                            list = null;
18651    
18652                                            break;
18653                                    }
18654                            }
18655                    }
18656    
18657                    if (list == null) {
18658                            StringBundler query = new StringBundler();
18659    
18660                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18661    
18662                            boolean conjunctionable = false;
18663    
18664                            if (conjunctionable) {
18665                                    query.append(WHERE_AND);
18666                            }
18667    
18668                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
18669    
18670                            conjunctionable = true;
18671    
18672                            if (conjunctionable) {
18673                                    query.append(WHERE_AND);
18674                            }
18675    
18676                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
18677    
18678                            conjunctionable = true;
18679    
18680                            if ((statuses == null) || (statuses.length > 0)) {
18681                                    if (conjunctionable) {
18682                                            query.append(WHERE_AND);
18683                                    }
18684    
18685                                    query.append(StringPool.OPEN_PARENTHESIS);
18686    
18687                                    for (int i = 0; i < statuses.length; i++) {
18688                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
18689    
18690                                            if ((i + 1) < statuses.length) {
18691                                                    query.append(WHERE_OR);
18692                                            }
18693                                    }
18694    
18695                                    query.append(StringPool.CLOSE_PARENTHESIS);
18696    
18697                                    conjunctionable = true;
18698                            }
18699    
18700                            if (orderByComparator != null) {
18701                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18702                                            orderByComparator);
18703                            }
18704                            else
18705                             if (pagination) {
18706                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18707                            }
18708    
18709                            String sql = query.toString();
18710    
18711                            Session session = null;
18712    
18713                            try {
18714                                    session = openSession();
18715    
18716                                    Query q = session.createQuery(sql);
18717    
18718                                    QueryPos qPos = QueryPos.getInstance(q);
18719    
18720                                    qPos.add(resourcePrimKey);
18721    
18722                                    qPos.add(indexable);
18723    
18724                                    if (statuses != null) {
18725                                            qPos.add(statuses);
18726                                    }
18727    
18728                                    if (!pagination) {
18729                                            list = (List<JournalArticle>)QueryUtil.list(q,
18730                                                            getDialect(), start, end, false);
18731    
18732                                            Collections.sort(list);
18733    
18734                                            list = new UnmodifiableList<JournalArticle>(list);
18735                                    }
18736                                    else {
18737                                            list = (List<JournalArticle>)QueryUtil.list(q,
18738                                                            getDialect(), start, end);
18739                                    }
18740    
18741                                    cacheResult(list);
18742    
18743                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18744                                            finderArgs, list);
18745                            }
18746                            catch (Exception e) {
18747                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18748                                            finderArgs);
18749    
18750                                    throw processException(e);
18751                            }
18752                            finally {
18753                                    closeSession(session);
18754                            }
18755                    }
18756    
18757                    return list;
18758            }
18759    
18760            /**
18761             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
18762             *
18763             * @param resourcePrimKey the resource prim key
18764             * @param indexable the indexable
18765             * @param status the status
18766             * @throws SystemException if a system exception occurred
18767             */
18768            @Override
18769            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
18770                    int status) throws SystemException {
18771                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
18772                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18773                            remove(journalArticle);
18774                    }
18775            }
18776    
18777            /**
18778             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18779             *
18780             * @param resourcePrimKey the resource prim key
18781             * @param indexable the indexable
18782             * @param status the status
18783             * @return the number of matching journal articles
18784             * @throws SystemException if a system exception occurred
18785             */
18786            @Override
18787            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status)
18788                    throws SystemException {
18789                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
18790    
18791                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
18792    
18793                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18794                                    this);
18795    
18796                    if (count == null) {
18797                            StringBundler query = new StringBundler(4);
18798    
18799                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18800    
18801                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18802    
18803                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18804    
18805                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18806    
18807                            String sql = query.toString();
18808    
18809                            Session session = null;
18810    
18811                            try {
18812                                    session = openSession();
18813    
18814                                    Query q = session.createQuery(sql);
18815    
18816                                    QueryPos qPos = QueryPos.getInstance(q);
18817    
18818                                    qPos.add(resourcePrimKey);
18819    
18820                                    qPos.add(indexable);
18821    
18822                                    qPos.add(status);
18823    
18824                                    count = (Long)q.uniqueResult();
18825    
18826                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18827                            }
18828                            catch (Exception e) {
18829                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18830    
18831                                    throw processException(e);
18832                            }
18833                            finally {
18834                                    closeSession(session);
18835                            }
18836                    }
18837    
18838                    return count.intValue();
18839            }
18840    
18841            /**
18842             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18843             *
18844             * @param resourcePrimKey the resource prim key
18845             * @param indexable the indexable
18846             * @param statuses the statuses
18847             * @return the number of matching journal articles
18848             * @throws SystemException if a system exception occurred
18849             */
18850            @Override
18851            public int countByR_I_S(long resourcePrimKey, boolean indexable,
18852                    int[] statuses) throws SystemException {
18853                    Object[] finderArgs = new Object[] {
18854                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
18855                            };
18856    
18857                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18858                                    finderArgs, this);
18859    
18860                    if (count == null) {
18861                            StringBundler query = new StringBundler();
18862    
18863                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18864    
18865                            boolean conjunctionable = false;
18866    
18867                            if (conjunctionable) {
18868                                    query.append(WHERE_AND);
18869                            }
18870    
18871                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
18872    
18873                            conjunctionable = true;
18874    
18875                            if (conjunctionable) {
18876                                    query.append(WHERE_AND);
18877                            }
18878    
18879                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
18880    
18881                            conjunctionable = true;
18882    
18883                            if ((statuses == null) || (statuses.length > 0)) {
18884                                    if (conjunctionable) {
18885                                            query.append(WHERE_AND);
18886                                    }
18887    
18888                                    query.append(StringPool.OPEN_PARENTHESIS);
18889    
18890                                    for (int i = 0; i < statuses.length; i++) {
18891                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
18892    
18893                                            if ((i + 1) < statuses.length) {
18894                                                    query.append(WHERE_OR);
18895                                            }
18896                                    }
18897    
18898                                    query.append(StringPool.CLOSE_PARENTHESIS);
18899    
18900                                    conjunctionable = true;
18901                            }
18902    
18903                            String sql = query.toString();
18904    
18905                            Session session = null;
18906    
18907                            try {
18908                                    session = openSession();
18909    
18910                                    Query q = session.createQuery(sql);
18911    
18912                                    QueryPos qPos = QueryPos.getInstance(q);
18913    
18914                                    qPos.add(resourcePrimKey);
18915    
18916                                    qPos.add(indexable);
18917    
18918                                    if (statuses != null) {
18919                                            qPos.add(statuses);
18920                                    }
18921    
18922                                    count = (Long)q.uniqueResult();
18923    
18924                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18925                                            finderArgs, count);
18926                            }
18927                            catch (Exception e) {
18928                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18929                                            finderArgs);
18930    
18931                                    throw processException(e);
18932                            }
18933                            finally {
18934                                    closeSession(session);
18935                            }
18936                    }
18937    
18938                    return count.intValue();
18939            }
18940    
18941            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
18942            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5 = "(" +
18943                    removeConjunction(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2) + ")";
18944            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
18945            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_5 = "(" +
18946                    removeConjunction(_FINDER_COLUMN_R_I_S_INDEXABLE_2) + ")";
18947            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
18948            private static final String _FINDER_COLUMN_R_I_S_STATUS_5 = "(" +
18949                    removeConjunction(_FINDER_COLUMN_R_I_S_STATUS_2) + ")";
18950            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18951                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18952                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18953                            "findByG_U_C",
18954                            new String[] {
18955                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
18956                                    
18957                            Integer.class.getName(), Integer.class.getName(),
18958                                    OrderByComparator.class.getName()
18959                            });
18960            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18961                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18962                            JournalArticleImpl.class,
18963                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
18964                            new String[] {
18965                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18966                            },
18967                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18968                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
18969                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18970                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18971                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18972            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18973                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18974                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
18975                            new String[] {
18976                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18977                            });
18978    
18979            /**
18980             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18981             *
18982             * @param groupId the group ID
18983             * @param userId the user ID
18984             * @param classNameId the class name ID
18985             * @return the matching journal articles
18986             * @throws SystemException if a system exception occurred
18987             */
18988            @Override
18989            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18990                    long classNameId) throws SystemException {
18991                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
18992                            QueryUtil.ALL_POS, null);
18993            }
18994    
18995            /**
18996             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18997             *
18998             * <p>
18999             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19000             * </p>
19001             *
19002             * @param groupId the group ID
19003             * @param userId the user ID
19004             * @param classNameId the class name ID
19005             * @param start the lower bound of the range of journal articles
19006             * @param end the upper bound of the range of journal articles (not inclusive)
19007             * @return the range of matching journal articles
19008             * @throws SystemException if a system exception occurred
19009             */
19010            @Override
19011            public List<JournalArticle> findByG_U_C(long groupId, long userId,
19012                    long classNameId, int start, int end) throws SystemException {
19013                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
19014            }
19015    
19016            /**
19017             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19018             *
19019             * <p>
19020             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19021             * </p>
19022             *
19023             * @param groupId the group ID
19024             * @param userId the user ID
19025             * @param classNameId the class name ID
19026             * @param start the lower bound of the range of journal articles
19027             * @param end the upper bound of the range of journal articles (not inclusive)
19028             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19029             * @return the ordered range of matching journal articles
19030             * @throws SystemException if a system exception occurred
19031             */
19032            @Override
19033            public List<JournalArticle> findByG_U_C(long groupId, long userId,
19034                    long classNameId, int start, int end,
19035                    OrderByComparator orderByComparator) throws SystemException {
19036                    boolean pagination = true;
19037                    FinderPath finderPath = null;
19038                    Object[] finderArgs = null;
19039    
19040                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19041                                    (orderByComparator == null)) {
19042                            pagination = false;
19043                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
19044                            finderArgs = new Object[] { groupId, userId, classNameId };
19045                    }
19046                    else {
19047                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
19048                            finderArgs = new Object[] {
19049                                            groupId, userId, classNameId,
19050                                            
19051                                            start, end, orderByComparator
19052                                    };
19053                    }
19054    
19055                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19056                                    finderArgs, this);
19057    
19058                    if ((list != null) && !list.isEmpty()) {
19059                            for (JournalArticle journalArticle : list) {
19060                                    if ((groupId != journalArticle.getGroupId()) ||
19061                                                    (userId != journalArticle.getUserId()) ||
19062                                                    (classNameId != journalArticle.getClassNameId())) {
19063                                            list = null;
19064    
19065                                            break;
19066                                    }
19067                            }
19068                    }
19069    
19070                    if (list == null) {
19071                            StringBundler query = null;
19072    
19073                            if (orderByComparator != null) {
19074                                    query = new StringBundler(5 +
19075                                                    (orderByComparator.getOrderByFields().length * 3));
19076                            }
19077                            else {
19078                                    query = new StringBundler(5);
19079                            }
19080    
19081                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19082    
19083                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19084    
19085                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19086    
19087                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19088    
19089                            if (orderByComparator != null) {
19090                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19091                                            orderByComparator);
19092                            }
19093                            else
19094                             if (pagination) {
19095                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19096                            }
19097    
19098                            String sql = query.toString();
19099    
19100                            Session session = null;
19101    
19102                            try {
19103                                    session = openSession();
19104    
19105                                    Query q = session.createQuery(sql);
19106    
19107                                    QueryPos qPos = QueryPos.getInstance(q);
19108    
19109                                    qPos.add(groupId);
19110    
19111                                    qPos.add(userId);
19112    
19113                                    qPos.add(classNameId);
19114    
19115                                    if (!pagination) {
19116                                            list = (List<JournalArticle>)QueryUtil.list(q,
19117                                                            getDialect(), start, end, false);
19118    
19119                                            Collections.sort(list);
19120    
19121                                            list = new UnmodifiableList<JournalArticle>(list);
19122                                    }
19123                                    else {
19124                                            list = (List<JournalArticle>)QueryUtil.list(q,
19125                                                            getDialect(), start, end);
19126                                    }
19127    
19128                                    cacheResult(list);
19129    
19130                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19131                            }
19132                            catch (Exception e) {
19133                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19134    
19135                                    throw processException(e);
19136                            }
19137                            finally {
19138                                    closeSession(session);
19139                            }
19140                    }
19141    
19142                    return list;
19143            }
19144    
19145            /**
19146             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19147             *
19148             * @param groupId the group ID
19149             * @param userId the user ID
19150             * @param classNameId the class name ID
19151             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19152             * @return the first matching journal article
19153             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19154             * @throws SystemException if a system exception occurred
19155             */
19156            @Override
19157            public JournalArticle findByG_U_C_First(long groupId, long userId,
19158                    long classNameId, OrderByComparator orderByComparator)
19159                    throws NoSuchArticleException, SystemException {
19160                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
19161                                    classNameId, orderByComparator);
19162    
19163                    if (journalArticle != null) {
19164                            return journalArticle;
19165                    }
19166    
19167                    StringBundler msg = new StringBundler(8);
19168    
19169                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19170    
19171                    msg.append("groupId=");
19172                    msg.append(groupId);
19173    
19174                    msg.append(", userId=");
19175                    msg.append(userId);
19176    
19177                    msg.append(", classNameId=");
19178                    msg.append(classNameId);
19179    
19180                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19181    
19182                    throw new NoSuchArticleException(msg.toString());
19183            }
19184    
19185            /**
19186             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19187             *
19188             * @param groupId the group ID
19189             * @param userId the user ID
19190             * @param classNameId the class name ID
19191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19192             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19193             * @throws SystemException if a system exception occurred
19194             */
19195            @Override
19196            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
19197                    long classNameId, OrderByComparator orderByComparator)
19198                    throws SystemException {
19199                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
19200                                    0, 1, orderByComparator);
19201    
19202                    if (!list.isEmpty()) {
19203                            return list.get(0);
19204                    }
19205    
19206                    return null;
19207            }
19208    
19209            /**
19210             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19211             *
19212             * @param groupId the group ID
19213             * @param userId the user ID
19214             * @param classNameId the class name ID
19215             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19216             * @return the last matching journal article
19217             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19218             * @throws SystemException if a system exception occurred
19219             */
19220            @Override
19221            public JournalArticle findByG_U_C_Last(long groupId, long userId,
19222                    long classNameId, OrderByComparator orderByComparator)
19223                    throws NoSuchArticleException, SystemException {
19224                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
19225                                    classNameId, orderByComparator);
19226    
19227                    if (journalArticle != null) {
19228                            return journalArticle;
19229                    }
19230    
19231                    StringBundler msg = new StringBundler(8);
19232    
19233                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19234    
19235                    msg.append("groupId=");
19236                    msg.append(groupId);
19237    
19238                    msg.append(", userId=");
19239                    msg.append(userId);
19240    
19241                    msg.append(", classNameId=");
19242                    msg.append(classNameId);
19243    
19244                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19245    
19246                    throw new NoSuchArticleException(msg.toString());
19247            }
19248    
19249            /**
19250             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19251             *
19252             * @param groupId the group ID
19253             * @param userId the user ID
19254             * @param classNameId the class name ID
19255             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19256             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19257             * @throws SystemException if a system exception occurred
19258             */
19259            @Override
19260            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
19261                    long classNameId, OrderByComparator orderByComparator)
19262                    throws SystemException {
19263                    int count = countByG_U_C(groupId, userId, classNameId);
19264    
19265                    if (count == 0) {
19266                            return null;
19267                    }
19268    
19269                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
19270                                    count - 1, count, orderByComparator);
19271    
19272                    if (!list.isEmpty()) {
19273                            return list.get(0);
19274                    }
19275    
19276                    return null;
19277            }
19278    
19279            /**
19280             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19281             *
19282             * @param id the primary key of the current journal article
19283             * @param groupId the group ID
19284             * @param userId the user ID
19285             * @param classNameId the class name ID
19286             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19287             * @return the previous, current, and next journal article
19288             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19289             * @throws SystemException if a system exception occurred
19290             */
19291            @Override
19292            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
19293                    long userId, long classNameId, OrderByComparator orderByComparator)
19294                    throws NoSuchArticleException, SystemException {
19295                    JournalArticle journalArticle = findByPrimaryKey(id);
19296    
19297                    Session session = null;
19298    
19299                    try {
19300                            session = openSession();
19301    
19302                            JournalArticle[] array = new JournalArticleImpl[3];
19303    
19304                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
19305                                            userId, classNameId, orderByComparator, true);
19306    
19307                            array[1] = journalArticle;
19308    
19309                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
19310                                            userId, classNameId, orderByComparator, false);
19311    
19312                            return array;
19313                    }
19314                    catch (Exception e) {
19315                            throw processException(e);
19316                    }
19317                    finally {
19318                            closeSession(session);
19319                    }
19320            }
19321    
19322            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
19323                    JournalArticle journalArticle, long groupId, long userId,
19324                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
19325                    StringBundler query = null;
19326    
19327                    if (orderByComparator != null) {
19328                            query = new StringBundler(6 +
19329                                            (orderByComparator.getOrderByFields().length * 6));
19330                    }
19331                    else {
19332                            query = new StringBundler(3);
19333                    }
19334    
19335                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19336    
19337                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19338    
19339                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19340    
19341                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19342    
19343                    if (orderByComparator != null) {
19344                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19345    
19346                            if (orderByConditionFields.length > 0) {
19347                                    query.append(WHERE_AND);
19348                            }
19349    
19350                            for (int i = 0; i < orderByConditionFields.length; i++) {
19351                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19352                                    query.append(orderByConditionFields[i]);
19353    
19354                                    if ((i + 1) < orderByConditionFields.length) {
19355                                            if (orderByComparator.isAscending() ^ previous) {
19356                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19357                                            }
19358                                            else {
19359                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19360                                            }
19361                                    }
19362                                    else {
19363                                            if (orderByComparator.isAscending() ^ previous) {
19364                                                    query.append(WHERE_GREATER_THAN);
19365                                            }
19366                                            else {
19367                                                    query.append(WHERE_LESSER_THAN);
19368                                            }
19369                                    }
19370                            }
19371    
19372                            query.append(ORDER_BY_CLAUSE);
19373    
19374                            String[] orderByFields = orderByComparator.getOrderByFields();
19375    
19376                            for (int i = 0; i < orderByFields.length; i++) {
19377                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19378                                    query.append(orderByFields[i]);
19379    
19380                                    if ((i + 1) < orderByFields.length) {
19381                                            if (orderByComparator.isAscending() ^ previous) {
19382                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19383                                            }
19384                                            else {
19385                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19386                                            }
19387                                    }
19388                                    else {
19389                                            if (orderByComparator.isAscending() ^ previous) {
19390                                                    query.append(ORDER_BY_ASC);
19391                                            }
19392                                            else {
19393                                                    query.append(ORDER_BY_DESC);
19394                                            }
19395                                    }
19396                            }
19397                    }
19398                    else {
19399                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19400                    }
19401    
19402                    String sql = query.toString();
19403    
19404                    Query q = session.createQuery(sql);
19405    
19406                    q.setFirstResult(0);
19407                    q.setMaxResults(2);
19408    
19409                    QueryPos qPos = QueryPos.getInstance(q);
19410    
19411                    qPos.add(groupId);
19412    
19413                    qPos.add(userId);
19414    
19415                    qPos.add(classNameId);
19416    
19417                    if (orderByComparator != null) {
19418                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19419    
19420                            for (Object value : values) {
19421                                    qPos.add(value);
19422                            }
19423                    }
19424    
19425                    List<JournalArticle> list = q.list();
19426    
19427                    if (list.size() == 2) {
19428                            return list.get(1);
19429                    }
19430                    else {
19431                            return null;
19432                    }
19433            }
19434    
19435            /**
19436             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19437             *
19438             * @param groupId the group ID
19439             * @param userId the user ID
19440             * @param classNameId the class name ID
19441             * @return the matching journal articles that the user has permission to view
19442             * @throws SystemException if a system exception occurred
19443             */
19444            @Override
19445            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
19446                    long classNameId) throws SystemException {
19447                    return filterFindByG_U_C(groupId, userId, classNameId,
19448                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19449            }
19450    
19451            /**
19452             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19453             *
19454             * <p>
19455             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19456             * </p>
19457             *
19458             * @param groupId the group ID
19459             * @param userId the user ID
19460             * @param classNameId the class name ID
19461             * @param start the lower bound of the range of journal articles
19462             * @param end the upper bound of the range of journal articles (not inclusive)
19463             * @return the range of matching journal articles that the user has permission to view
19464             * @throws SystemException if a system exception occurred
19465             */
19466            @Override
19467            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
19468                    long classNameId, int start, int end) throws SystemException {
19469                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
19470            }
19471    
19472            /**
19473             * 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;.
19474             *
19475             * <p>
19476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19477             * </p>
19478             *
19479             * @param groupId the group ID
19480             * @param userId the user ID
19481             * @param classNameId the class name ID
19482             * @param start the lower bound of the range of journal articles
19483             * @param end the upper bound of the range of journal articles (not inclusive)
19484             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19485             * @return the ordered range of matching journal articles that the user has permission to view
19486             * @throws SystemException if a system exception occurred
19487             */
19488            @Override
19489            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
19490                    long classNameId, int start, int end,
19491                    OrderByComparator orderByComparator) throws SystemException {
19492                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19493                            return findByG_U_C(groupId, userId, classNameId, start, end,
19494                                    orderByComparator);
19495                    }
19496    
19497                    StringBundler query = null;
19498    
19499                    if (orderByComparator != null) {
19500                            query = new StringBundler(5 +
19501                                            (orderByComparator.getOrderByFields().length * 3));
19502                    }
19503                    else {
19504                            query = new StringBundler(5);
19505                    }
19506    
19507                    if (getDB().isSupportsInlineDistinct()) {
19508                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19509                    }
19510                    else {
19511                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19512                    }
19513    
19514                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19515    
19516                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19517    
19518                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19519    
19520                    if (!getDB().isSupportsInlineDistinct()) {
19521                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19522                    }
19523    
19524                    if (orderByComparator != null) {
19525                            if (getDB().isSupportsInlineDistinct()) {
19526                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19527                                            orderByComparator, true);
19528                            }
19529                            else {
19530                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19531                                            orderByComparator, true);
19532                            }
19533                    }
19534                    else {
19535                            if (getDB().isSupportsInlineDistinct()) {
19536                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19537                            }
19538                            else {
19539                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19540                            }
19541                    }
19542    
19543                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19544                                    JournalArticle.class.getName(),
19545                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19546    
19547                    Session session = null;
19548    
19549                    try {
19550                            session = openSession();
19551    
19552                            SQLQuery q = session.createSQLQuery(sql);
19553    
19554                            if (getDB().isSupportsInlineDistinct()) {
19555                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19556                            }
19557                            else {
19558                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19559                            }
19560    
19561                            QueryPos qPos = QueryPos.getInstance(q);
19562    
19563                            qPos.add(groupId);
19564    
19565                            qPos.add(userId);
19566    
19567                            qPos.add(classNameId);
19568    
19569                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19570                                    end);
19571                    }
19572                    catch (Exception e) {
19573                            throw processException(e);
19574                    }
19575                    finally {
19576                            closeSession(session);
19577                    }
19578            }
19579    
19580            /**
19581             * 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;.
19582             *
19583             * @param id the primary key of the current journal article
19584             * @param groupId the group ID
19585             * @param userId the user ID
19586             * @param classNameId the class name ID
19587             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19588             * @return the previous, current, and next journal article
19589             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19590             * @throws SystemException if a system exception occurred
19591             */
19592            @Override
19593            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
19594                    long groupId, long userId, long classNameId,
19595                    OrderByComparator orderByComparator)
19596                    throws NoSuchArticleException, SystemException {
19597                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19598                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
19599                                    orderByComparator);
19600                    }
19601    
19602                    JournalArticle journalArticle = findByPrimaryKey(id);
19603    
19604                    Session session = null;
19605    
19606                    try {
19607                            session = openSession();
19608    
19609                            JournalArticle[] array = new JournalArticleImpl[3];
19610    
19611                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19612                                            groupId, userId, classNameId, orderByComparator, true);
19613    
19614                            array[1] = journalArticle;
19615    
19616                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19617                                            groupId, userId, classNameId, orderByComparator, false);
19618    
19619                            return array;
19620                    }
19621                    catch (Exception e) {
19622                            throw processException(e);
19623                    }
19624                    finally {
19625                            closeSession(session);
19626                    }
19627            }
19628    
19629            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
19630                    JournalArticle journalArticle, long groupId, long userId,
19631                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
19632                    StringBundler query = null;
19633    
19634                    if (orderByComparator != null) {
19635                            query = new StringBundler(6 +
19636                                            (orderByComparator.getOrderByFields().length * 6));
19637                    }
19638                    else {
19639                            query = new StringBundler(3);
19640                    }
19641    
19642                    if (getDB().isSupportsInlineDistinct()) {
19643                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19644                    }
19645                    else {
19646                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19647                    }
19648    
19649                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19650    
19651                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19652    
19653                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19654    
19655                    if (!getDB().isSupportsInlineDistinct()) {
19656                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19657                    }
19658    
19659                    if (orderByComparator != null) {
19660                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19661    
19662                            if (orderByConditionFields.length > 0) {
19663                                    query.append(WHERE_AND);
19664                            }
19665    
19666                            for (int i = 0; i < orderByConditionFields.length; i++) {
19667                                    if (getDB().isSupportsInlineDistinct()) {
19668                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19669                                    }
19670                                    else {
19671                                            query.append(_ORDER_BY_ENTITY_TABLE);
19672                                    }
19673    
19674                                    query.append(orderByConditionFields[i]);
19675    
19676                                    if ((i + 1) < orderByConditionFields.length) {
19677                                            if (orderByComparator.isAscending() ^ previous) {
19678                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19679                                            }
19680                                            else {
19681                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19682                                            }
19683                                    }
19684                                    else {
19685                                            if (orderByComparator.isAscending() ^ previous) {
19686                                                    query.append(WHERE_GREATER_THAN);
19687                                            }
19688                                            else {
19689                                                    query.append(WHERE_LESSER_THAN);
19690                                            }
19691                                    }
19692                            }
19693    
19694                            query.append(ORDER_BY_CLAUSE);
19695    
19696                            String[] orderByFields = orderByComparator.getOrderByFields();
19697    
19698                            for (int i = 0; i < orderByFields.length; i++) {
19699                                    if (getDB().isSupportsInlineDistinct()) {
19700                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19701                                    }
19702                                    else {
19703                                            query.append(_ORDER_BY_ENTITY_TABLE);
19704                                    }
19705    
19706                                    query.append(orderByFields[i]);
19707    
19708                                    if ((i + 1) < orderByFields.length) {
19709                                            if (orderByComparator.isAscending() ^ previous) {
19710                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19711                                            }
19712                                            else {
19713                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19714                                            }
19715                                    }
19716                                    else {
19717                                            if (orderByComparator.isAscending() ^ previous) {
19718                                                    query.append(ORDER_BY_ASC);
19719                                            }
19720                                            else {
19721                                                    query.append(ORDER_BY_DESC);
19722                                            }
19723                                    }
19724                            }
19725                    }
19726                    else {
19727                            if (getDB().isSupportsInlineDistinct()) {
19728                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19729                            }
19730                            else {
19731                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19732                            }
19733                    }
19734    
19735                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19736                                    JournalArticle.class.getName(),
19737                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19738    
19739                    SQLQuery q = session.createSQLQuery(sql);
19740    
19741                    q.setFirstResult(0);
19742                    q.setMaxResults(2);
19743    
19744                    if (getDB().isSupportsInlineDistinct()) {
19745                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19746                    }
19747                    else {
19748                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19749                    }
19750    
19751                    QueryPos qPos = QueryPos.getInstance(q);
19752    
19753                    qPos.add(groupId);
19754    
19755                    qPos.add(userId);
19756    
19757                    qPos.add(classNameId);
19758    
19759                    if (orderByComparator != null) {
19760                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19761    
19762                            for (Object value : values) {
19763                                    qPos.add(value);
19764                            }
19765                    }
19766    
19767                    List<JournalArticle> list = q.list();
19768    
19769                    if (list.size() == 2) {
19770                            return list.get(1);
19771                    }
19772                    else {
19773                            return null;
19774                    }
19775            }
19776    
19777            /**
19778             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
19779             *
19780             * @param groupId the group ID
19781             * @param userId the user ID
19782             * @param classNameId the class name ID
19783             * @throws SystemException if a system exception occurred
19784             */
19785            @Override
19786            public void removeByG_U_C(long groupId, long userId, long classNameId)
19787                    throws SystemException {
19788                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
19789                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19790                            remove(journalArticle);
19791                    }
19792            }
19793    
19794            /**
19795             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19796             *
19797             * @param groupId the group ID
19798             * @param userId the user ID
19799             * @param classNameId the class name ID
19800             * @return the number of matching journal articles
19801             * @throws SystemException if a system exception occurred
19802             */
19803            @Override
19804            public int countByG_U_C(long groupId, long userId, long classNameId)
19805                    throws SystemException {
19806                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
19807    
19808                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
19809    
19810                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19811                                    this);
19812    
19813                    if (count == null) {
19814                            StringBundler query = new StringBundler(4);
19815    
19816                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19817    
19818                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19819    
19820                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19821    
19822                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19823    
19824                            String sql = query.toString();
19825    
19826                            Session session = null;
19827    
19828                            try {
19829                                    session = openSession();
19830    
19831                                    Query q = session.createQuery(sql);
19832    
19833                                    QueryPos qPos = QueryPos.getInstance(q);
19834    
19835                                    qPos.add(groupId);
19836    
19837                                    qPos.add(userId);
19838    
19839                                    qPos.add(classNameId);
19840    
19841                                    count = (Long)q.uniqueResult();
19842    
19843                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19844                            }
19845                            catch (Exception e) {
19846                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19847    
19848                                    throw processException(e);
19849                            }
19850                            finally {
19851                                    closeSession(session);
19852                            }
19853                    }
19854    
19855                    return count.intValue();
19856            }
19857    
19858            /**
19859             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19860             *
19861             * @param groupId the group ID
19862             * @param userId the user ID
19863             * @param classNameId the class name ID
19864             * @return the number of matching journal articles that the user has permission to view
19865             * @throws SystemException if a system exception occurred
19866             */
19867            @Override
19868            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
19869                    throws SystemException {
19870                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19871                            return countByG_U_C(groupId, userId, classNameId);
19872                    }
19873    
19874                    StringBundler query = new StringBundler(4);
19875    
19876                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19877    
19878                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19879    
19880                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19881    
19882                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19883    
19884                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19885                                    JournalArticle.class.getName(),
19886                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19887    
19888                    Session session = null;
19889    
19890                    try {
19891                            session = openSession();
19892    
19893                            SQLQuery q = session.createSQLQuery(sql);
19894    
19895                            q.addScalar(COUNT_COLUMN_NAME,
19896                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19897    
19898                            QueryPos qPos = QueryPos.getInstance(q);
19899    
19900                            qPos.add(groupId);
19901    
19902                            qPos.add(userId);
19903    
19904                            qPos.add(classNameId);
19905    
19906                            Long count = (Long)q.uniqueResult();
19907    
19908                            return count.intValue();
19909                    }
19910                    catch (Exception e) {
19911                            throw processException(e);
19912                    }
19913                    finally {
19914                            closeSession(session);
19915                    }
19916            }
19917    
19918            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
19919            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
19920            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
19921            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19922                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19923                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19924                            "findByG_F_ST",
19925                            new String[] {
19926                                    Long.class.getName(), Long.class.getName(),
19927                                    Integer.class.getName(),
19928                                    
19929                            Integer.class.getName(), Integer.class.getName(),
19930                                    OrderByComparator.class.getName()
19931                            });
19932            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
19933                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19934                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19935                            JournalArticleImpl.class,
19936                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
19937                            new String[] {
19938                                    Long.class.getName(), Long.class.getName(),
19939                                    Integer.class.getName()
19940                            },
19941                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19942                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
19943                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
19944                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19945                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19946            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19947                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19948                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
19949                            new String[] {
19950                                    Long.class.getName(), Long.class.getName(),
19951                                    Integer.class.getName()
19952                            });
19953            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19954                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19955                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
19956                            new String[] {
19957                                    Long.class.getName(), Long.class.getName(),
19958                                    Integer.class.getName()
19959                            });
19960    
19961            /**
19962             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19963             *
19964             * @param groupId the group ID
19965             * @param folderId the folder ID
19966             * @param status the status
19967             * @return the matching journal articles
19968             * @throws SystemException if a system exception occurred
19969             */
19970            @Override
19971            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19972                    int status) throws SystemException {
19973                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19974                            QueryUtil.ALL_POS, null);
19975            }
19976    
19977            /**
19978             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19979             *
19980             * <p>
19981             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19982             * </p>
19983             *
19984             * @param groupId the group ID
19985             * @param folderId the folder ID
19986             * @param status the status
19987             * @param start the lower bound of the range of journal articles
19988             * @param end the upper bound of the range of journal articles (not inclusive)
19989             * @return the range of matching journal articles
19990             * @throws SystemException if a system exception occurred
19991             */
19992            @Override
19993            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19994                    int status, int start, int end) throws SystemException {
19995                    return findByG_F_ST(groupId, folderId, status, start, end, null);
19996            }
19997    
19998            /**
19999             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
20000             *
20001             * <p>
20002             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20003             * </p>
20004             *
20005             * @param groupId the group ID
20006             * @param folderId the folder ID
20007             * @param status the status
20008             * @param start the lower bound of the range of journal articles
20009             * @param end the upper bound of the range of journal articles (not inclusive)
20010             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20011             * @return the ordered range of matching journal articles
20012             * @throws SystemException if a system exception occurred
20013             */
20014            @Override
20015            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20016                    int status, int start, int end, OrderByComparator orderByComparator)
20017                    throws SystemException {
20018                    boolean pagination = true;
20019                    FinderPath finderPath = null;
20020                    Object[] finderArgs = null;
20021    
20022                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20023                                    (orderByComparator == null)) {
20024                            pagination = false;
20025                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
20026                            finderArgs = new Object[] { groupId, folderId, status };
20027                    }
20028                    else {
20029                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
20030                            finderArgs = new Object[] {
20031                                            groupId, folderId, status,
20032                                            
20033                                            start, end, orderByComparator
20034                                    };
20035                    }
20036    
20037                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20038                                    finderArgs, this);
20039    
20040                    if ((list != null) && !list.isEmpty()) {
20041                            for (JournalArticle journalArticle : list) {
20042                                    if ((groupId != journalArticle.getGroupId()) ||
20043                                                    (folderId != journalArticle.getFolderId()) ||
20044                                                    (status != journalArticle.getStatus())) {
20045                                            list = null;
20046    
20047                                            break;
20048                                    }
20049                            }
20050                    }
20051    
20052                    if (list == null) {
20053                            StringBundler query = null;
20054    
20055                            if (orderByComparator != null) {
20056                                    query = new StringBundler(5 +
20057                                                    (orderByComparator.getOrderByFields().length * 3));
20058                            }
20059                            else {
20060                                    query = new StringBundler(5);
20061                            }
20062    
20063                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20064    
20065                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20066    
20067                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20068    
20069                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20070    
20071                            if (orderByComparator != null) {
20072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20073                                            orderByComparator);
20074                            }
20075                            else
20076                             if (pagination) {
20077                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20078                            }
20079    
20080                            String sql = query.toString();
20081    
20082                            Session session = null;
20083    
20084                            try {
20085                                    session = openSession();
20086    
20087                                    Query q = session.createQuery(sql);
20088    
20089                                    QueryPos qPos = QueryPos.getInstance(q);
20090    
20091                                    qPos.add(groupId);
20092    
20093                                    qPos.add(folderId);
20094    
20095                                    qPos.add(status);
20096    
20097                                    if (!pagination) {
20098                                            list = (List<JournalArticle>)QueryUtil.list(q,
20099                                                            getDialect(), start, end, false);
20100    
20101                                            Collections.sort(list);
20102    
20103                                            list = new UnmodifiableList<JournalArticle>(list);
20104                                    }
20105                                    else {
20106                                            list = (List<JournalArticle>)QueryUtil.list(q,
20107                                                            getDialect(), start, end);
20108                                    }
20109    
20110                                    cacheResult(list);
20111    
20112                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20113                            }
20114                            catch (Exception e) {
20115                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20116    
20117                                    throw processException(e);
20118                            }
20119                            finally {
20120                                    closeSession(session);
20121                            }
20122                    }
20123    
20124                    return list;
20125            }
20126    
20127            /**
20128             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20129             *
20130             * @param groupId the group ID
20131             * @param folderId the folder ID
20132             * @param status the status
20133             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20134             * @return the first matching journal article
20135             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20136             * @throws SystemException if a system exception occurred
20137             */
20138            @Override
20139            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
20140                    int status, OrderByComparator orderByComparator)
20141                    throws NoSuchArticleException, SystemException {
20142                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
20143                                    status, orderByComparator);
20144    
20145                    if (journalArticle != null) {
20146                            return journalArticle;
20147                    }
20148    
20149                    StringBundler msg = new StringBundler(8);
20150    
20151                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20152    
20153                    msg.append("groupId=");
20154                    msg.append(groupId);
20155    
20156                    msg.append(", folderId=");
20157                    msg.append(folderId);
20158    
20159                    msg.append(", status=");
20160                    msg.append(status);
20161    
20162                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20163    
20164                    throw new NoSuchArticleException(msg.toString());
20165            }
20166    
20167            /**
20168             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20169             *
20170             * @param groupId the group ID
20171             * @param folderId the folder ID
20172             * @param status the status
20173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20174             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
20175             * @throws SystemException if a system exception occurred
20176             */
20177            @Override
20178            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
20179                    int status, OrderByComparator orderByComparator)
20180                    throws SystemException {
20181                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
20182                                    1, orderByComparator);
20183    
20184                    if (!list.isEmpty()) {
20185                            return list.get(0);
20186                    }
20187    
20188                    return null;
20189            }
20190    
20191            /**
20192             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20193             *
20194             * @param groupId the group ID
20195             * @param folderId the folder ID
20196             * @param status the status
20197             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20198             * @return the last matching journal article
20199             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20200             * @throws SystemException if a system exception occurred
20201             */
20202            @Override
20203            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
20204                    int status, OrderByComparator orderByComparator)
20205                    throws NoSuchArticleException, SystemException {
20206                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
20207                                    status, orderByComparator);
20208    
20209                    if (journalArticle != null) {
20210                            return journalArticle;
20211                    }
20212    
20213                    StringBundler msg = new StringBundler(8);
20214    
20215                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20216    
20217                    msg.append("groupId=");
20218                    msg.append(groupId);
20219    
20220                    msg.append(", folderId=");
20221                    msg.append(folderId);
20222    
20223                    msg.append(", status=");
20224                    msg.append(status);
20225    
20226                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20227    
20228                    throw new NoSuchArticleException(msg.toString());
20229            }
20230    
20231            /**
20232             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20233             *
20234             * @param groupId the group ID
20235             * @param folderId the folder ID
20236             * @param status the status
20237             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20238             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20239             * @throws SystemException if a system exception occurred
20240             */
20241            @Override
20242            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
20243                    int status, OrderByComparator orderByComparator)
20244                    throws SystemException {
20245                    int count = countByG_F_ST(groupId, folderId, status);
20246    
20247                    if (count == 0) {
20248                            return null;
20249                    }
20250    
20251                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
20252                                    count - 1, count, orderByComparator);
20253    
20254                    if (!list.isEmpty()) {
20255                            return list.get(0);
20256                    }
20257    
20258                    return null;
20259            }
20260    
20261            /**
20262             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20263             *
20264             * @param id the primary key of the current journal article
20265             * @param groupId the group ID
20266             * @param folderId the folder ID
20267             * @param status the status
20268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20269             * @return the previous, current, and next journal article
20270             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20271             * @throws SystemException if a system exception occurred
20272             */
20273            @Override
20274            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
20275                    long folderId, int status, OrderByComparator orderByComparator)
20276                    throws NoSuchArticleException, SystemException {
20277                    JournalArticle journalArticle = findByPrimaryKey(id);
20278    
20279                    Session session = null;
20280    
20281                    try {
20282                            session = openSession();
20283    
20284                            JournalArticle[] array = new JournalArticleImpl[3];
20285    
20286                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
20287                                            groupId, folderId, status, orderByComparator, true);
20288    
20289                            array[1] = journalArticle;
20290    
20291                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
20292                                            groupId, folderId, status, orderByComparator, false);
20293    
20294                            return array;
20295                    }
20296                    catch (Exception e) {
20297                            throw processException(e);
20298                    }
20299                    finally {
20300                            closeSession(session);
20301                    }
20302            }
20303    
20304            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
20305                    JournalArticle journalArticle, long groupId, long folderId, int status,
20306                    OrderByComparator orderByComparator, boolean previous) {
20307                    StringBundler query = null;
20308    
20309                    if (orderByComparator != null) {
20310                            query = new StringBundler(6 +
20311                                            (orderByComparator.getOrderByFields().length * 6));
20312                    }
20313                    else {
20314                            query = new StringBundler(3);
20315                    }
20316    
20317                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20318    
20319                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20320    
20321                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20322    
20323                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20324    
20325                    if (orderByComparator != null) {
20326                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20327    
20328                            if (orderByConditionFields.length > 0) {
20329                                    query.append(WHERE_AND);
20330                            }
20331    
20332                            for (int i = 0; i < orderByConditionFields.length; i++) {
20333                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20334                                    query.append(orderByConditionFields[i]);
20335    
20336                                    if ((i + 1) < orderByConditionFields.length) {
20337                                            if (orderByComparator.isAscending() ^ previous) {
20338                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20339                                            }
20340                                            else {
20341                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20342                                            }
20343                                    }
20344                                    else {
20345                                            if (orderByComparator.isAscending() ^ previous) {
20346                                                    query.append(WHERE_GREATER_THAN);
20347                                            }
20348                                            else {
20349                                                    query.append(WHERE_LESSER_THAN);
20350                                            }
20351                                    }
20352                            }
20353    
20354                            query.append(ORDER_BY_CLAUSE);
20355    
20356                            String[] orderByFields = orderByComparator.getOrderByFields();
20357    
20358                            for (int i = 0; i < orderByFields.length; i++) {
20359                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20360                                    query.append(orderByFields[i]);
20361    
20362                                    if ((i + 1) < orderByFields.length) {
20363                                            if (orderByComparator.isAscending() ^ previous) {
20364                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20365                                            }
20366                                            else {
20367                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20368                                            }
20369                                    }
20370                                    else {
20371                                            if (orderByComparator.isAscending() ^ previous) {
20372                                                    query.append(ORDER_BY_ASC);
20373                                            }
20374                                            else {
20375                                                    query.append(ORDER_BY_DESC);
20376                                            }
20377                                    }
20378                            }
20379                    }
20380                    else {
20381                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20382                    }
20383    
20384                    String sql = query.toString();
20385    
20386                    Query q = session.createQuery(sql);
20387    
20388                    q.setFirstResult(0);
20389                    q.setMaxResults(2);
20390    
20391                    QueryPos qPos = QueryPos.getInstance(q);
20392    
20393                    qPos.add(groupId);
20394    
20395                    qPos.add(folderId);
20396    
20397                    qPos.add(status);
20398    
20399                    if (orderByComparator != null) {
20400                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20401    
20402                            for (Object value : values) {
20403                                    qPos.add(value);
20404                            }
20405                    }
20406    
20407                    List<JournalArticle> list = q.list();
20408    
20409                    if (list.size() == 2) {
20410                            return list.get(1);
20411                    }
20412                    else {
20413                            return null;
20414                    }
20415            }
20416    
20417            /**
20418             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20419             *
20420             * @param groupId the group ID
20421             * @param folderId the folder ID
20422             * @param status the status
20423             * @return the matching journal articles that the user has permission to view
20424             * @throws SystemException if a system exception occurred
20425             */
20426            @Override
20427            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20428                    int status) throws SystemException {
20429                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
20430                            QueryUtil.ALL_POS, null);
20431            }
20432    
20433            /**
20434             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20435             *
20436             * <p>
20437             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20438             * </p>
20439             *
20440             * @param groupId the group ID
20441             * @param folderId the folder ID
20442             * @param status the status
20443             * @param start the lower bound of the range of journal articles
20444             * @param end the upper bound of the range of journal articles (not inclusive)
20445             * @return the range of matching journal articles that the user has permission to view
20446             * @throws SystemException if a system exception occurred
20447             */
20448            @Override
20449            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20450                    int status, int start, int end) throws SystemException {
20451                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
20452            }
20453    
20454            /**
20455             * 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;.
20456             *
20457             * <p>
20458             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20459             * </p>
20460             *
20461             * @param groupId the group ID
20462             * @param folderId the folder ID
20463             * @param status the status
20464             * @param start the lower bound of the range of journal articles
20465             * @param end the upper bound of the range of journal articles (not inclusive)
20466             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20467             * @return the ordered range of matching journal articles that the user has permission to view
20468             * @throws SystemException if a system exception occurred
20469             */
20470            @Override
20471            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20472                    int status, int start, int end, OrderByComparator orderByComparator)
20473                    throws SystemException {
20474                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20475                            return findByG_F_ST(groupId, folderId, status, start, end,
20476                                    orderByComparator);
20477                    }
20478    
20479                    StringBundler query = null;
20480    
20481                    if (orderByComparator != null) {
20482                            query = new StringBundler(5 +
20483                                            (orderByComparator.getOrderByFields().length * 3));
20484                    }
20485                    else {
20486                            query = new StringBundler(5);
20487                    }
20488    
20489                    if (getDB().isSupportsInlineDistinct()) {
20490                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20491                    }
20492                    else {
20493                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20494                    }
20495    
20496                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20497    
20498                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20499    
20500                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20501    
20502                    if (!getDB().isSupportsInlineDistinct()) {
20503                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20504                    }
20505    
20506                    if (orderByComparator != null) {
20507                            if (getDB().isSupportsInlineDistinct()) {
20508                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20509                                            orderByComparator, true);
20510                            }
20511                            else {
20512                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20513                                            orderByComparator, true);
20514                            }
20515                    }
20516                    else {
20517                            if (getDB().isSupportsInlineDistinct()) {
20518                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20519                            }
20520                            else {
20521                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20522                            }
20523                    }
20524    
20525                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20526                                    JournalArticle.class.getName(),
20527                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20528    
20529                    Session session = null;
20530    
20531                    try {
20532                            session = openSession();
20533    
20534                            SQLQuery q = session.createSQLQuery(sql);
20535    
20536                            if (getDB().isSupportsInlineDistinct()) {
20537                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20538                            }
20539                            else {
20540                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20541                            }
20542    
20543                            QueryPos qPos = QueryPos.getInstance(q);
20544    
20545                            qPos.add(groupId);
20546    
20547                            qPos.add(folderId);
20548    
20549                            qPos.add(status);
20550    
20551                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20552                                    end);
20553                    }
20554                    catch (Exception e) {
20555                            throw processException(e);
20556                    }
20557                    finally {
20558                            closeSession(session);
20559                    }
20560            }
20561    
20562            /**
20563             * 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;.
20564             *
20565             * @param id the primary key of the current journal article
20566             * @param groupId the group ID
20567             * @param folderId the folder ID
20568             * @param status the status
20569             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20570             * @return the previous, current, and next journal article
20571             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20572             * @throws SystemException if a system exception occurred
20573             */
20574            @Override
20575            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
20576                    long groupId, long folderId, int status,
20577                    OrderByComparator orderByComparator)
20578                    throws NoSuchArticleException, SystemException {
20579                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20580                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
20581                                    orderByComparator);
20582                    }
20583    
20584                    JournalArticle journalArticle = findByPrimaryKey(id);
20585    
20586                    Session session = null;
20587    
20588                    try {
20589                            session = openSession();
20590    
20591                            JournalArticle[] array = new JournalArticleImpl[3];
20592    
20593                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20594                                            groupId, folderId, status, orderByComparator, true);
20595    
20596                            array[1] = journalArticle;
20597    
20598                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20599                                            groupId, folderId, status, orderByComparator, false);
20600    
20601                            return array;
20602                    }
20603                    catch (Exception e) {
20604                            throw processException(e);
20605                    }
20606                    finally {
20607                            closeSession(session);
20608                    }
20609            }
20610    
20611            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
20612                    JournalArticle journalArticle, long groupId, long folderId, int status,
20613                    OrderByComparator orderByComparator, boolean previous) {
20614                    StringBundler query = null;
20615    
20616                    if (orderByComparator != null) {
20617                            query = new StringBundler(6 +
20618                                            (orderByComparator.getOrderByFields().length * 6));
20619                    }
20620                    else {
20621                            query = new StringBundler(3);
20622                    }
20623    
20624                    if (getDB().isSupportsInlineDistinct()) {
20625                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20626                    }
20627                    else {
20628                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20629                    }
20630    
20631                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20632    
20633                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20634    
20635                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20636    
20637                    if (!getDB().isSupportsInlineDistinct()) {
20638                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20639                    }
20640    
20641                    if (orderByComparator != null) {
20642                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20643    
20644                            if (orderByConditionFields.length > 0) {
20645                                    query.append(WHERE_AND);
20646                            }
20647    
20648                            for (int i = 0; i < orderByConditionFields.length; i++) {
20649                                    if (getDB().isSupportsInlineDistinct()) {
20650                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20651                                    }
20652                                    else {
20653                                            query.append(_ORDER_BY_ENTITY_TABLE);
20654                                    }
20655    
20656                                    query.append(orderByConditionFields[i]);
20657    
20658                                    if ((i + 1) < orderByConditionFields.length) {
20659                                            if (orderByComparator.isAscending() ^ previous) {
20660                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20661                                            }
20662                                            else {
20663                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20664                                            }
20665                                    }
20666                                    else {
20667                                            if (orderByComparator.isAscending() ^ previous) {
20668                                                    query.append(WHERE_GREATER_THAN);
20669                                            }
20670                                            else {
20671                                                    query.append(WHERE_LESSER_THAN);
20672                                            }
20673                                    }
20674                            }
20675    
20676                            query.append(ORDER_BY_CLAUSE);
20677    
20678                            String[] orderByFields = orderByComparator.getOrderByFields();
20679    
20680                            for (int i = 0; i < orderByFields.length; i++) {
20681                                    if (getDB().isSupportsInlineDistinct()) {
20682                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20683                                    }
20684                                    else {
20685                                            query.append(_ORDER_BY_ENTITY_TABLE);
20686                                    }
20687    
20688                                    query.append(orderByFields[i]);
20689    
20690                                    if ((i + 1) < orderByFields.length) {
20691                                            if (orderByComparator.isAscending() ^ previous) {
20692                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20693                                            }
20694                                            else {
20695                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20696                                            }
20697                                    }
20698                                    else {
20699                                            if (orderByComparator.isAscending() ^ previous) {
20700                                                    query.append(ORDER_BY_ASC);
20701                                            }
20702                                            else {
20703                                                    query.append(ORDER_BY_DESC);
20704                                            }
20705                                    }
20706                            }
20707                    }
20708                    else {
20709                            if (getDB().isSupportsInlineDistinct()) {
20710                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20711                            }
20712                            else {
20713                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20714                            }
20715                    }
20716    
20717                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20718                                    JournalArticle.class.getName(),
20719                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20720    
20721                    SQLQuery q = session.createSQLQuery(sql);
20722    
20723                    q.setFirstResult(0);
20724                    q.setMaxResults(2);
20725    
20726                    if (getDB().isSupportsInlineDistinct()) {
20727                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20728                    }
20729                    else {
20730                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20731                    }
20732    
20733                    QueryPos qPos = QueryPos.getInstance(q);
20734    
20735                    qPos.add(groupId);
20736    
20737                    qPos.add(folderId);
20738    
20739                    qPos.add(status);
20740    
20741                    if (orderByComparator != null) {
20742                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20743    
20744                            for (Object value : values) {
20745                                    qPos.add(value);
20746                            }
20747                    }
20748    
20749                    List<JournalArticle> list = q.list();
20750    
20751                    if (list.size() == 2) {
20752                            return list.get(1);
20753                    }
20754                    else {
20755                            return null;
20756                    }
20757            }
20758    
20759            /**
20760             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20761             *
20762             * @param groupId the group ID
20763             * @param folderId the folder ID
20764             * @param statuses the statuses
20765             * @return the matching journal articles that the user has permission to view
20766             * @throws SystemException if a system exception occurred
20767             */
20768            @Override
20769            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20770                    int[] statuses) throws SystemException {
20771                    return filterFindByG_F_ST(groupId, folderId, statuses,
20772                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20773            }
20774    
20775            /**
20776             * 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;.
20777             *
20778             * <p>
20779             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20780             * </p>
20781             *
20782             * @param groupId the group ID
20783             * @param folderId the folder ID
20784             * @param statuses the statuses
20785             * @param start the lower bound of the range of journal articles
20786             * @param end the upper bound of the range of journal articles (not inclusive)
20787             * @return the range of matching journal articles that the user has permission to view
20788             * @throws SystemException if a system exception occurred
20789             */
20790            @Override
20791            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20792                    int[] statuses, int start, int end) throws SystemException {
20793                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
20794            }
20795    
20796            /**
20797             * 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;.
20798             *
20799             * <p>
20800             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20801             * </p>
20802             *
20803             * @param groupId the group ID
20804             * @param folderId the folder ID
20805             * @param statuses the statuses
20806             * @param start the lower bound of the range of journal articles
20807             * @param end the upper bound of the range of journal articles (not inclusive)
20808             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20809             * @return the ordered range of matching journal articles that the user has permission to view
20810             * @throws SystemException if a system exception occurred
20811             */
20812            @Override
20813            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20814                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
20815                    throws SystemException {
20816                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20817                            return findByG_F_ST(groupId, folderId, statuses, start, end,
20818                                    orderByComparator);
20819                    }
20820    
20821                    StringBundler query = new StringBundler();
20822    
20823                    if (getDB().isSupportsInlineDistinct()) {
20824                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20825                    }
20826                    else {
20827                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20828                    }
20829    
20830                    boolean conjunctionable = false;
20831    
20832                    if (conjunctionable) {
20833                            query.append(WHERE_AND);
20834                    }
20835    
20836                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
20837    
20838                    conjunctionable = true;
20839    
20840                    if (conjunctionable) {
20841                            query.append(WHERE_AND);
20842                    }
20843    
20844                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
20845    
20846                    conjunctionable = true;
20847    
20848                    if ((statuses == null) || (statuses.length > 0)) {
20849                            if (conjunctionable) {
20850                                    query.append(WHERE_AND);
20851                            }
20852    
20853                            query.append(StringPool.OPEN_PARENTHESIS);
20854    
20855                            for (int i = 0; i < statuses.length; i++) {
20856                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
20857    
20858                                    if ((i + 1) < statuses.length) {
20859                                            query.append(WHERE_OR);
20860                                    }
20861                            }
20862    
20863                            query.append(StringPool.CLOSE_PARENTHESIS);
20864    
20865                            conjunctionable = true;
20866                    }
20867    
20868                    if (!getDB().isSupportsInlineDistinct()) {
20869                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20870                    }
20871    
20872                    if (orderByComparator != null) {
20873                            if (getDB().isSupportsInlineDistinct()) {
20874                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20875                                            orderByComparator, true);
20876                            }
20877                            else {
20878                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20879                                            orderByComparator, true);
20880                            }
20881                    }
20882                    else {
20883                            if (getDB().isSupportsInlineDistinct()) {
20884                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20885                            }
20886                            else {
20887                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20888                            }
20889                    }
20890    
20891                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20892                                    JournalArticle.class.getName(),
20893                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20894    
20895                    Session session = null;
20896    
20897                    try {
20898                            session = openSession();
20899    
20900                            SQLQuery q = session.createSQLQuery(sql);
20901    
20902                            if (getDB().isSupportsInlineDistinct()) {
20903                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20904                            }
20905                            else {
20906                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20907                            }
20908    
20909                            QueryPos qPos = QueryPos.getInstance(q);
20910    
20911                            qPos.add(groupId);
20912    
20913                            qPos.add(folderId);
20914    
20915                            if (statuses != null) {
20916                                    qPos.add(statuses);
20917                            }
20918    
20919                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20920                                    end);
20921                    }
20922                    catch (Exception e) {
20923                            throw processException(e);
20924                    }
20925                    finally {
20926                            closeSession(session);
20927                    }
20928            }
20929    
20930            /**
20931             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20932             *
20933             * <p>
20934             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20935             * </p>
20936             *
20937             * @param groupId the group ID
20938             * @param folderId the folder ID
20939             * @param statuses the statuses
20940             * @return the matching journal articles
20941             * @throws SystemException if a system exception occurred
20942             */
20943            @Override
20944            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20945                    int[] statuses) throws SystemException {
20946                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
20947                            QueryUtil.ALL_POS, null);
20948            }
20949    
20950            /**
20951             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20952             *
20953             * <p>
20954             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20955             * </p>
20956             *
20957             * @param groupId the group ID
20958             * @param folderId the folder ID
20959             * @param statuses the statuses
20960             * @param start the lower bound of the range of journal articles
20961             * @param end the upper bound of the range of journal articles (not inclusive)
20962             * @return the range of matching journal articles
20963             * @throws SystemException if a system exception occurred
20964             */
20965            @Override
20966            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20967                    int[] statuses, int start, int end) throws SystemException {
20968                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
20969            }
20970    
20971            /**
20972             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20973             *
20974             * <p>
20975             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20976             * </p>
20977             *
20978             * @param groupId the group ID
20979             * @param folderId the folder ID
20980             * @param statuses the statuses
20981             * @param start the lower bound of the range of journal articles
20982             * @param end the upper bound of the range of journal articles (not inclusive)
20983             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20984             * @return the ordered range of matching journal articles
20985             * @throws SystemException if a system exception occurred
20986             */
20987            @Override
20988            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20989                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
20990                    throws SystemException {
20991                    if ((statuses != null) && (statuses.length == 1)) {
20992                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
20993                                    orderByComparator);
20994                    }
20995    
20996                    boolean pagination = true;
20997                    Object[] finderArgs = null;
20998    
20999                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21000                                    (orderByComparator == null)) {
21001                            pagination = false;
21002                            finderArgs = new Object[] {
21003                                            groupId, folderId, StringUtil.merge(statuses)
21004                                    };
21005                    }
21006                    else {
21007                            finderArgs = new Object[] {
21008                                            groupId, folderId, StringUtil.merge(statuses),
21009                                            
21010                                            start, end, orderByComparator
21011                                    };
21012                    }
21013    
21014                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
21015                                    finderArgs, this);
21016    
21017                    if ((list != null) && !list.isEmpty()) {
21018                            for (JournalArticle journalArticle : list) {
21019                                    if ((groupId != journalArticle.getGroupId()) ||
21020                                                    (folderId != journalArticle.getFolderId()) ||
21021                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
21022                                            list = null;
21023    
21024                                            break;
21025                                    }
21026                            }
21027                    }
21028    
21029                    if (list == null) {
21030                            StringBundler query = new StringBundler();
21031    
21032                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21033    
21034                            boolean conjunctionable = false;
21035    
21036                            if (conjunctionable) {
21037                                    query.append(WHERE_AND);
21038                            }
21039    
21040                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
21041    
21042                            conjunctionable = true;
21043    
21044                            if (conjunctionable) {
21045                                    query.append(WHERE_AND);
21046                            }
21047    
21048                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
21049    
21050                            conjunctionable = true;
21051    
21052                            if ((statuses == null) || (statuses.length > 0)) {
21053                                    if (conjunctionable) {
21054                                            query.append(WHERE_AND);
21055                                    }
21056    
21057                                    query.append(StringPool.OPEN_PARENTHESIS);
21058    
21059                                    for (int i = 0; i < statuses.length; i++) {
21060                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
21061    
21062                                            if ((i + 1) < statuses.length) {
21063                                                    query.append(WHERE_OR);
21064                                            }
21065                                    }
21066    
21067                                    query.append(StringPool.CLOSE_PARENTHESIS);
21068    
21069                                    conjunctionable = true;
21070                            }
21071    
21072                            if (orderByComparator != null) {
21073                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21074                                            orderByComparator);
21075                            }
21076                            else
21077                             if (pagination) {
21078                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21079                            }
21080    
21081                            String sql = query.toString();
21082    
21083                            Session session = null;
21084    
21085                            try {
21086                                    session = openSession();
21087    
21088                                    Query q = session.createQuery(sql);
21089    
21090                                    QueryPos qPos = QueryPos.getInstance(q);
21091    
21092                                    qPos.add(groupId);
21093    
21094                                    qPos.add(folderId);
21095    
21096                                    if (statuses != null) {
21097                                            qPos.add(statuses);
21098                                    }
21099    
21100                                    if (!pagination) {
21101                                            list = (List<JournalArticle>)QueryUtil.list(q,
21102                                                            getDialect(), start, end, false);
21103    
21104                                            Collections.sort(list);
21105    
21106                                            list = new UnmodifiableList<JournalArticle>(list);
21107                                    }
21108                                    else {
21109                                            list = (List<JournalArticle>)QueryUtil.list(q,
21110                                                            getDialect(), start, end);
21111                                    }
21112    
21113                                    cacheResult(list);
21114    
21115                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
21116                                            finderArgs, list);
21117                            }
21118                            catch (Exception e) {
21119                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
21120                                            finderArgs);
21121    
21122                                    throw processException(e);
21123                            }
21124                            finally {
21125                                    closeSession(session);
21126                            }
21127                    }
21128    
21129                    return list;
21130            }
21131    
21132            /**
21133             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
21134             *
21135             * @param groupId the group ID
21136             * @param folderId the folder ID
21137             * @param status the status
21138             * @throws SystemException if a system exception occurred
21139             */
21140            @Override
21141            public void removeByG_F_ST(long groupId, long folderId, int status)
21142                    throws SystemException {
21143                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
21144                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21145                            remove(journalArticle);
21146                    }
21147            }
21148    
21149            /**
21150             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
21151             *
21152             * @param groupId the group ID
21153             * @param folderId the folder ID
21154             * @param status the status
21155             * @return the number of matching journal articles
21156             * @throws SystemException if a system exception occurred
21157             */
21158            @Override
21159            public int countByG_F_ST(long groupId, long folderId, int status)
21160                    throws SystemException {
21161                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
21162    
21163                    Object[] finderArgs = new Object[] { groupId, folderId, status };
21164    
21165                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21166                                    this);
21167    
21168                    if (count == null) {
21169                            StringBundler query = new StringBundler(4);
21170    
21171                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21172    
21173                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
21174    
21175                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
21176    
21177                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
21178    
21179                            String sql = query.toString();
21180    
21181                            Session session = null;
21182    
21183                            try {
21184                                    session = openSession();
21185    
21186                                    Query q = session.createQuery(sql);
21187    
21188                                    QueryPos qPos = QueryPos.getInstance(q);
21189    
21190                                    qPos.add(groupId);
21191    
21192                                    qPos.add(folderId);
21193    
21194                                    qPos.add(status);
21195    
21196                                    count = (Long)q.uniqueResult();
21197    
21198                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21199                            }
21200                            catch (Exception e) {
21201                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21202    
21203                                    throw processException(e);
21204                            }
21205                            finally {
21206                                    closeSession(session);
21207                            }
21208                    }
21209    
21210                    return count.intValue();
21211            }
21212    
21213            /**
21214             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
21215             *
21216             * @param groupId the group ID
21217             * @param folderId the folder ID
21218             * @param statuses the statuses
21219             * @return the number of matching journal articles
21220             * @throws SystemException if a system exception occurred
21221             */
21222            @Override
21223            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
21224                    throws SystemException {
21225                    Object[] finderArgs = new Object[] {
21226                                    groupId, folderId, StringUtil.merge(statuses)
21227                            };
21228    
21229                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
21230                                    finderArgs, this);
21231    
21232                    if (count == null) {
21233                            StringBundler query = new StringBundler();
21234    
21235                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21236    
21237                            boolean conjunctionable = false;
21238    
21239                            if (conjunctionable) {
21240                                    query.append(WHERE_AND);
21241                            }
21242    
21243                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
21244    
21245                            conjunctionable = true;
21246    
21247                            if (conjunctionable) {
21248                                    query.append(WHERE_AND);
21249                            }
21250    
21251                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
21252    
21253                            conjunctionable = true;
21254    
21255                            if ((statuses == null) || (statuses.length > 0)) {
21256                                    if (conjunctionable) {
21257                                            query.append(WHERE_AND);
21258                                    }
21259    
21260                                    query.append(StringPool.OPEN_PARENTHESIS);
21261    
21262                                    for (int i = 0; i < statuses.length; i++) {
21263                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
21264    
21265                                            if ((i + 1) < statuses.length) {
21266                                                    query.append(WHERE_OR);
21267                                            }
21268                                    }
21269    
21270                                    query.append(StringPool.CLOSE_PARENTHESIS);
21271    
21272                                    conjunctionable = true;
21273                            }
21274    
21275                            String sql = query.toString();
21276    
21277                            Session session = null;
21278    
21279                            try {
21280                                    session = openSession();
21281    
21282                                    Query q = session.createQuery(sql);
21283    
21284                                    QueryPos qPos = QueryPos.getInstance(q);
21285    
21286                                    qPos.add(groupId);
21287    
21288                                    qPos.add(folderId);
21289    
21290                                    if (statuses != null) {
21291                                            qPos.add(statuses);
21292                                    }
21293    
21294                                    count = (Long)q.uniqueResult();
21295    
21296                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
21297                                            finderArgs, count);
21298                            }
21299                            catch (Exception e) {
21300                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
21301                                            finderArgs);
21302    
21303                                    throw processException(e);
21304                            }
21305                            finally {
21306                                    closeSession(session);
21307                            }
21308                    }
21309    
21310                    return count.intValue();
21311            }
21312    
21313            /**
21314             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
21315             *
21316             * @param groupId the group ID
21317             * @param folderId the folder ID
21318             * @param status the status
21319             * @return the number of matching journal articles that the user has permission to view
21320             * @throws SystemException if a system exception occurred
21321             */
21322            @Override
21323            public int filterCountByG_F_ST(long groupId, long folderId, int status)
21324                    throws SystemException {
21325                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21326                            return countByG_F_ST(groupId, folderId, status);
21327                    }
21328    
21329                    StringBundler query = new StringBundler(4);
21330    
21331                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21332    
21333                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
21334    
21335                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
21336    
21337                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
21338    
21339                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21340                                    JournalArticle.class.getName(),
21341                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21342    
21343                    Session session = null;
21344    
21345                    try {
21346                            session = openSession();
21347    
21348                            SQLQuery q = session.createSQLQuery(sql);
21349    
21350                            q.addScalar(COUNT_COLUMN_NAME,
21351                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21352    
21353                            QueryPos qPos = QueryPos.getInstance(q);
21354    
21355                            qPos.add(groupId);
21356    
21357                            qPos.add(folderId);
21358    
21359                            qPos.add(status);
21360    
21361                            Long count = (Long)q.uniqueResult();
21362    
21363                            return count.intValue();
21364                    }
21365                    catch (Exception e) {
21366                            throw processException(e);
21367                    }
21368                    finally {
21369                            closeSession(session);
21370                    }
21371            }
21372    
21373            /**
21374             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
21375             *
21376             * @param groupId the group ID
21377             * @param folderId the folder ID
21378             * @param statuses the statuses
21379             * @return the number of matching journal articles that the user has permission to view
21380             * @throws SystemException if a system exception occurred
21381             */
21382            @Override
21383            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
21384                    throws SystemException {
21385                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21386                            return countByG_F_ST(groupId, folderId, statuses);
21387                    }
21388    
21389                    StringBundler query = new StringBundler();
21390    
21391                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21392    
21393                    boolean conjunctionable = false;
21394    
21395                    if (conjunctionable) {
21396                            query.append(WHERE_AND);
21397                    }
21398    
21399                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
21400    
21401                    conjunctionable = true;
21402    
21403                    if (conjunctionable) {
21404                            query.append(WHERE_AND);
21405                    }
21406    
21407                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
21408    
21409                    conjunctionable = true;
21410    
21411                    if ((statuses == null) || (statuses.length > 0)) {
21412                            if (conjunctionable) {
21413                                    query.append(WHERE_AND);
21414                            }
21415    
21416                            query.append(StringPool.OPEN_PARENTHESIS);
21417    
21418                            for (int i = 0; i < statuses.length; i++) {
21419                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
21420    
21421                                    if ((i + 1) < statuses.length) {
21422                                            query.append(WHERE_OR);
21423                                    }
21424                            }
21425    
21426                            query.append(StringPool.CLOSE_PARENTHESIS);
21427    
21428                            conjunctionable = true;
21429                    }
21430    
21431                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21432                                    JournalArticle.class.getName(),
21433                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21434    
21435                    Session session = null;
21436    
21437                    try {
21438                            session = openSession();
21439    
21440                            SQLQuery q = session.createSQLQuery(sql);
21441    
21442                            q.addScalar(COUNT_COLUMN_NAME,
21443                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21444    
21445                            QueryPos qPos = QueryPos.getInstance(q);
21446    
21447                            qPos.add(groupId);
21448    
21449                            qPos.add(folderId);
21450    
21451                            if (statuses != null) {
21452                                    qPos.add(statuses);
21453                            }
21454    
21455                            Long count = (Long)q.uniqueResult();
21456    
21457                            return count.intValue();
21458                    }
21459                    catch (Exception e) {
21460                            throw processException(e);
21461                    }
21462                    finally {
21463                            closeSession(session);
21464                    }
21465            }
21466    
21467            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
21468            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
21469                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
21470            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
21471            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
21472                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
21473            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
21474            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
21475                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
21476            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21477                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21478                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
21479                            "findByG_C_C",
21480                            new String[] {
21481                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
21482                                    
21483                            Integer.class.getName(), Integer.class.getName(),
21484                                    OrderByComparator.class.getName()
21485                            });
21486            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21487                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21488                            JournalArticleImpl.class,
21489                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
21490                            new String[] {
21491                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
21492                            },
21493                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21494                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
21495                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
21496                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21497                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21498            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21499                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21500                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
21501                            new String[] {
21502                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
21503                            });
21504    
21505            /**
21506             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21507             *
21508             * @param groupId the group ID
21509             * @param classNameId the class name ID
21510             * @param classPK the class p k
21511             * @return the matching journal articles
21512             * @throws SystemException if a system exception occurred
21513             */
21514            @Override
21515            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
21516                    long classPK) throws SystemException {
21517                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
21518                            QueryUtil.ALL_POS, null);
21519            }
21520    
21521            /**
21522             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21523             *
21524             * <p>
21525             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21526             * </p>
21527             *
21528             * @param groupId the group ID
21529             * @param classNameId the class name ID
21530             * @param classPK the class p k
21531             * @param start the lower bound of the range of journal articles
21532             * @param end the upper bound of the range of journal articles (not inclusive)
21533             * @return the range of matching journal articles
21534             * @throws SystemException if a system exception occurred
21535             */
21536            @Override
21537            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
21538                    long classPK, int start, int end) throws SystemException {
21539                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
21540            }
21541    
21542            /**
21543             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21544             *
21545             * <p>
21546             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21547             * </p>
21548             *
21549             * @param groupId the group ID
21550             * @param classNameId the class name ID
21551             * @param classPK the class p k
21552             * @param start the lower bound of the range of journal articles
21553             * @param end the upper bound of the range of journal articles (not inclusive)
21554             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21555             * @return the ordered range of matching journal articles
21556             * @throws SystemException if a system exception occurred
21557             */
21558            @Override
21559            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
21560                    long classPK, int start, int end, OrderByComparator orderByComparator)
21561                    throws SystemException {
21562                    boolean pagination = true;
21563                    FinderPath finderPath = null;
21564                    Object[] finderArgs = null;
21565    
21566                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21567                                    (orderByComparator == null)) {
21568                            pagination = false;
21569                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
21570                            finderArgs = new Object[] { groupId, classNameId, classPK };
21571                    }
21572                    else {
21573                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
21574                            finderArgs = new Object[] {
21575                                            groupId, classNameId, classPK,
21576                                            
21577                                            start, end, orderByComparator
21578                                    };
21579                    }
21580    
21581                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21582                                    finderArgs, this);
21583    
21584                    if ((list != null) && !list.isEmpty()) {
21585                            for (JournalArticle journalArticle : list) {
21586                                    if ((groupId != journalArticle.getGroupId()) ||
21587                                                    (classNameId != journalArticle.getClassNameId()) ||
21588                                                    (classPK != journalArticle.getClassPK())) {
21589                                            list = null;
21590    
21591                                            break;
21592                                    }
21593                            }
21594                    }
21595    
21596                    if (list == null) {
21597                            StringBundler query = null;
21598    
21599                            if (orderByComparator != null) {
21600                                    query = new StringBundler(5 +
21601                                                    (orderByComparator.getOrderByFields().length * 3));
21602                            }
21603                            else {
21604                                    query = new StringBundler(5);
21605                            }
21606    
21607                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21608    
21609                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21610    
21611                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21612    
21613                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21614    
21615                            if (orderByComparator != null) {
21616                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21617                                            orderByComparator);
21618                            }
21619                            else
21620                             if (pagination) {
21621                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21622                            }
21623    
21624                            String sql = query.toString();
21625    
21626                            Session session = null;
21627    
21628                            try {
21629                                    session = openSession();
21630    
21631                                    Query q = session.createQuery(sql);
21632    
21633                                    QueryPos qPos = QueryPos.getInstance(q);
21634    
21635                                    qPos.add(groupId);
21636    
21637                                    qPos.add(classNameId);
21638    
21639                                    qPos.add(classPK);
21640    
21641                                    if (!pagination) {
21642                                            list = (List<JournalArticle>)QueryUtil.list(q,
21643                                                            getDialect(), start, end, false);
21644    
21645                                            Collections.sort(list);
21646    
21647                                            list = new UnmodifiableList<JournalArticle>(list);
21648                                    }
21649                                    else {
21650                                            list = (List<JournalArticle>)QueryUtil.list(q,
21651                                                            getDialect(), start, end);
21652                                    }
21653    
21654                                    cacheResult(list);
21655    
21656                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21657                            }
21658                            catch (Exception e) {
21659                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21660    
21661                                    throw processException(e);
21662                            }
21663                            finally {
21664                                    closeSession(session);
21665                            }
21666                    }
21667    
21668                    return list;
21669            }
21670    
21671            /**
21672             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21673             *
21674             * @param groupId the group ID
21675             * @param classNameId the class name ID
21676             * @param classPK the class p k
21677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21678             * @return the first matching journal article
21679             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21680             * @throws SystemException if a system exception occurred
21681             */
21682            @Override
21683            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
21684                    long classPK, OrderByComparator orderByComparator)
21685                    throws NoSuchArticleException, SystemException {
21686                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
21687                                    classNameId, classPK, orderByComparator);
21688    
21689                    if (journalArticle != null) {
21690                            return journalArticle;
21691                    }
21692    
21693                    StringBundler msg = new StringBundler(8);
21694    
21695                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21696    
21697                    msg.append("groupId=");
21698                    msg.append(groupId);
21699    
21700                    msg.append(", classNameId=");
21701                    msg.append(classNameId);
21702    
21703                    msg.append(", classPK=");
21704                    msg.append(classPK);
21705    
21706                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21707    
21708                    throw new NoSuchArticleException(msg.toString());
21709            }
21710    
21711            /**
21712             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21713             *
21714             * @param groupId the group ID
21715             * @param classNameId the class name ID
21716             * @param classPK the class p k
21717             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21718             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21719             * @throws SystemException if a system exception occurred
21720             */
21721            @Override
21722            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
21723                    long classPK, OrderByComparator orderByComparator)
21724                    throws SystemException {
21725                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21726                                    0, 1, orderByComparator);
21727    
21728                    if (!list.isEmpty()) {
21729                            return list.get(0);
21730                    }
21731    
21732                    return null;
21733            }
21734    
21735            /**
21736             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21737             *
21738             * @param groupId the group ID
21739             * @param classNameId the class name ID
21740             * @param classPK the class p k
21741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21742             * @return the last matching journal article
21743             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21744             * @throws SystemException if a system exception occurred
21745             */
21746            @Override
21747            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
21748                    long classPK, OrderByComparator orderByComparator)
21749                    throws NoSuchArticleException, SystemException {
21750                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
21751                                    classPK, orderByComparator);
21752    
21753                    if (journalArticle != null) {
21754                            return journalArticle;
21755                    }
21756    
21757                    StringBundler msg = new StringBundler(8);
21758    
21759                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21760    
21761                    msg.append("groupId=");
21762                    msg.append(groupId);
21763    
21764                    msg.append(", classNameId=");
21765                    msg.append(classNameId);
21766    
21767                    msg.append(", classPK=");
21768                    msg.append(classPK);
21769    
21770                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21771    
21772                    throw new NoSuchArticleException(msg.toString());
21773            }
21774    
21775            /**
21776             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21777             *
21778             * @param groupId the group ID
21779             * @param classNameId the class name ID
21780             * @param classPK the class p k
21781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21782             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21783             * @throws SystemException if a system exception occurred
21784             */
21785            @Override
21786            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
21787                    long classPK, OrderByComparator orderByComparator)
21788                    throws SystemException {
21789                    int count = countByG_C_C(groupId, classNameId, classPK);
21790    
21791                    if (count == 0) {
21792                            return null;
21793                    }
21794    
21795                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21796                                    count - 1, count, orderByComparator);
21797    
21798                    if (!list.isEmpty()) {
21799                            return list.get(0);
21800                    }
21801    
21802                    return null;
21803            }
21804    
21805            /**
21806             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21807             *
21808             * @param id the primary key of the current journal article
21809             * @param groupId the group ID
21810             * @param classNameId the class name ID
21811             * @param classPK the class p k
21812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21813             * @return the previous, current, and next journal article
21814             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21815             * @throws SystemException if a system exception occurred
21816             */
21817            @Override
21818            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
21819                    long classNameId, long classPK, OrderByComparator orderByComparator)
21820                    throws NoSuchArticleException, SystemException {
21821                    JournalArticle journalArticle = findByPrimaryKey(id);
21822    
21823                    Session session = null;
21824    
21825                    try {
21826                            session = openSession();
21827    
21828                            JournalArticle[] array = new JournalArticleImpl[3];
21829    
21830                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21831                                            classNameId, classPK, orderByComparator, true);
21832    
21833                            array[1] = journalArticle;
21834    
21835                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21836                                            classNameId, classPK, orderByComparator, false);
21837    
21838                            return array;
21839                    }
21840                    catch (Exception e) {
21841                            throw processException(e);
21842                    }
21843                    finally {
21844                            closeSession(session);
21845                    }
21846            }
21847    
21848            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
21849                    JournalArticle journalArticle, long groupId, long classNameId,
21850                    long classPK, OrderByComparator orderByComparator, boolean previous) {
21851                    StringBundler query = null;
21852    
21853                    if (orderByComparator != null) {
21854                            query = new StringBundler(6 +
21855                                            (orderByComparator.getOrderByFields().length * 6));
21856                    }
21857                    else {
21858                            query = new StringBundler(3);
21859                    }
21860    
21861                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21862    
21863                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21864    
21865                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21866    
21867                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21868    
21869                    if (orderByComparator != null) {
21870                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21871    
21872                            if (orderByConditionFields.length > 0) {
21873                                    query.append(WHERE_AND);
21874                            }
21875    
21876                            for (int i = 0; i < orderByConditionFields.length; i++) {
21877                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21878                                    query.append(orderByConditionFields[i]);
21879    
21880                                    if ((i + 1) < orderByConditionFields.length) {
21881                                            if (orderByComparator.isAscending() ^ previous) {
21882                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21883                                            }
21884                                            else {
21885                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21886                                            }
21887                                    }
21888                                    else {
21889                                            if (orderByComparator.isAscending() ^ previous) {
21890                                                    query.append(WHERE_GREATER_THAN);
21891                                            }
21892                                            else {
21893                                                    query.append(WHERE_LESSER_THAN);
21894                                            }
21895                                    }
21896                            }
21897    
21898                            query.append(ORDER_BY_CLAUSE);
21899    
21900                            String[] orderByFields = orderByComparator.getOrderByFields();
21901    
21902                            for (int i = 0; i < orderByFields.length; i++) {
21903                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21904                                    query.append(orderByFields[i]);
21905    
21906                                    if ((i + 1) < orderByFields.length) {
21907                                            if (orderByComparator.isAscending() ^ previous) {
21908                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21909                                            }
21910                                            else {
21911                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21912                                            }
21913                                    }
21914                                    else {
21915                                            if (orderByComparator.isAscending() ^ previous) {
21916                                                    query.append(ORDER_BY_ASC);
21917                                            }
21918                                            else {
21919                                                    query.append(ORDER_BY_DESC);
21920                                            }
21921                                    }
21922                            }
21923                    }
21924                    else {
21925                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21926                    }
21927    
21928                    String sql = query.toString();
21929    
21930                    Query q = session.createQuery(sql);
21931    
21932                    q.setFirstResult(0);
21933                    q.setMaxResults(2);
21934    
21935                    QueryPos qPos = QueryPos.getInstance(q);
21936    
21937                    qPos.add(groupId);
21938    
21939                    qPos.add(classNameId);
21940    
21941                    qPos.add(classPK);
21942    
21943                    if (orderByComparator != null) {
21944                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21945    
21946                            for (Object value : values) {
21947                                    qPos.add(value);
21948                            }
21949                    }
21950    
21951                    List<JournalArticle> list = q.list();
21952    
21953                    if (list.size() == 2) {
21954                            return list.get(1);
21955                    }
21956                    else {
21957                            return null;
21958                    }
21959            }
21960    
21961            /**
21962             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21963             *
21964             * @param groupId the group ID
21965             * @param classNameId the class name ID
21966             * @param classPK the class p k
21967             * @return the matching journal articles that the user has permission to view
21968             * @throws SystemException if a system exception occurred
21969             */
21970            @Override
21971            public List<JournalArticle> filterFindByG_C_C(long groupId,
21972                    long classNameId, long classPK) throws SystemException {
21973                    return filterFindByG_C_C(groupId, classNameId, classPK,
21974                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21975            }
21976    
21977            /**
21978             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21979             *
21980             * <p>
21981             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21982             * </p>
21983             *
21984             * @param groupId the group ID
21985             * @param classNameId the class name ID
21986             * @param classPK the class p k
21987             * @param start the lower bound of the range of journal articles
21988             * @param end the upper bound of the range of journal articles (not inclusive)
21989             * @return the range of matching journal articles that the user has permission to view
21990             * @throws SystemException if a system exception occurred
21991             */
21992            @Override
21993            public List<JournalArticle> filterFindByG_C_C(long groupId,
21994                    long classNameId, long classPK, int start, int end)
21995                    throws SystemException {
21996                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
21997            }
21998    
21999            /**
22000             * 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;.
22001             *
22002             * <p>
22003             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22004             * </p>
22005             *
22006             * @param groupId the group ID
22007             * @param classNameId the class name ID
22008             * @param classPK the class p k
22009             * @param start the lower bound of the range of journal articles
22010             * @param end the upper bound of the range of journal articles (not inclusive)
22011             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22012             * @return the ordered range of matching journal articles that the user has permission to view
22013             * @throws SystemException if a system exception occurred
22014             */
22015            @Override
22016            public List<JournalArticle> filterFindByG_C_C(long groupId,
22017                    long classNameId, long classPK, int start, int end,
22018                    OrderByComparator orderByComparator) throws SystemException {
22019                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22020                            return findByG_C_C(groupId, classNameId, classPK, start, end,
22021                                    orderByComparator);
22022                    }
22023    
22024                    StringBundler query = null;
22025    
22026                    if (orderByComparator != null) {
22027                            query = new StringBundler(5 +
22028                                            (orderByComparator.getOrderByFields().length * 3));
22029                    }
22030                    else {
22031                            query = new StringBundler(5);
22032                    }
22033    
22034                    if (getDB().isSupportsInlineDistinct()) {
22035                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22036                    }
22037                    else {
22038                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22039                    }
22040    
22041                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22042    
22043                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22044    
22045                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22046    
22047                    if (!getDB().isSupportsInlineDistinct()) {
22048                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22049                    }
22050    
22051                    if (orderByComparator != null) {
22052                            if (getDB().isSupportsInlineDistinct()) {
22053                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22054                                            orderByComparator, true);
22055                            }
22056                            else {
22057                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22058                                            orderByComparator, true);
22059                            }
22060                    }
22061                    else {
22062                            if (getDB().isSupportsInlineDistinct()) {
22063                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22064                            }
22065                            else {
22066                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22067                            }
22068                    }
22069    
22070                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22071                                    JournalArticle.class.getName(),
22072                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22073    
22074                    Session session = null;
22075    
22076                    try {
22077                            session = openSession();
22078    
22079                            SQLQuery q = session.createSQLQuery(sql);
22080    
22081                            if (getDB().isSupportsInlineDistinct()) {
22082                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22083                            }
22084                            else {
22085                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22086                            }
22087    
22088                            QueryPos qPos = QueryPos.getInstance(q);
22089    
22090                            qPos.add(groupId);
22091    
22092                            qPos.add(classNameId);
22093    
22094                            qPos.add(classPK);
22095    
22096                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22097                                    end);
22098                    }
22099                    catch (Exception e) {
22100                            throw processException(e);
22101                    }
22102                    finally {
22103                            closeSession(session);
22104                    }
22105            }
22106    
22107            /**
22108             * 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;.
22109             *
22110             * @param id the primary key of the current journal article
22111             * @param groupId the group ID
22112             * @param classNameId the class name ID
22113             * @param classPK the class p k
22114             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22115             * @return the previous, current, and next journal article
22116             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22117             * @throws SystemException if a system exception occurred
22118             */
22119            @Override
22120            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
22121                    long groupId, long classNameId, long classPK,
22122                    OrderByComparator orderByComparator)
22123                    throws NoSuchArticleException, SystemException {
22124                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22125                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
22126                                    orderByComparator);
22127                    }
22128    
22129                    JournalArticle journalArticle = findByPrimaryKey(id);
22130    
22131                    Session session = null;
22132    
22133                    try {
22134                            session = openSession();
22135    
22136                            JournalArticle[] array = new JournalArticleImpl[3];
22137    
22138                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
22139                                            groupId, classNameId, classPK, orderByComparator, true);
22140    
22141                            array[1] = journalArticle;
22142    
22143                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
22144                                            groupId, classNameId, classPK, orderByComparator, false);
22145    
22146                            return array;
22147                    }
22148                    catch (Exception e) {
22149                            throw processException(e);
22150                    }
22151                    finally {
22152                            closeSession(session);
22153                    }
22154            }
22155    
22156            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
22157                    JournalArticle journalArticle, long groupId, long classNameId,
22158                    long classPK, OrderByComparator orderByComparator, boolean previous) {
22159                    StringBundler query = null;
22160    
22161                    if (orderByComparator != null) {
22162                            query = new StringBundler(6 +
22163                                            (orderByComparator.getOrderByFields().length * 6));
22164                    }
22165                    else {
22166                            query = new StringBundler(3);
22167                    }
22168    
22169                    if (getDB().isSupportsInlineDistinct()) {
22170                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22171                    }
22172                    else {
22173                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22174                    }
22175    
22176                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22177    
22178                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22179    
22180                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22181    
22182                    if (!getDB().isSupportsInlineDistinct()) {
22183                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22184                    }
22185    
22186                    if (orderByComparator != null) {
22187                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22188    
22189                            if (orderByConditionFields.length > 0) {
22190                                    query.append(WHERE_AND);
22191                            }
22192    
22193                            for (int i = 0; i < orderByConditionFields.length; i++) {
22194                                    if (getDB().isSupportsInlineDistinct()) {
22195                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22196                                    }
22197                                    else {
22198                                            query.append(_ORDER_BY_ENTITY_TABLE);
22199                                    }
22200    
22201                                    query.append(orderByConditionFields[i]);
22202    
22203                                    if ((i + 1) < orderByConditionFields.length) {
22204                                            if (orderByComparator.isAscending() ^ previous) {
22205                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22206                                            }
22207                                            else {
22208                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22209                                            }
22210                                    }
22211                                    else {
22212                                            if (orderByComparator.isAscending() ^ previous) {
22213                                                    query.append(WHERE_GREATER_THAN);
22214                                            }
22215                                            else {
22216                                                    query.append(WHERE_LESSER_THAN);
22217                                            }
22218                                    }
22219                            }
22220    
22221                            query.append(ORDER_BY_CLAUSE);
22222    
22223                            String[] orderByFields = orderByComparator.getOrderByFields();
22224    
22225                            for (int i = 0; i < orderByFields.length; i++) {
22226                                    if (getDB().isSupportsInlineDistinct()) {
22227                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22228                                    }
22229                                    else {
22230                                            query.append(_ORDER_BY_ENTITY_TABLE);
22231                                    }
22232    
22233                                    query.append(orderByFields[i]);
22234    
22235                                    if ((i + 1) < orderByFields.length) {
22236                                            if (orderByComparator.isAscending() ^ previous) {
22237                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22238                                            }
22239                                            else {
22240                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22241                                            }
22242                                    }
22243                                    else {
22244                                            if (orderByComparator.isAscending() ^ previous) {
22245                                                    query.append(ORDER_BY_ASC);
22246                                            }
22247                                            else {
22248                                                    query.append(ORDER_BY_DESC);
22249                                            }
22250                                    }
22251                            }
22252                    }
22253                    else {
22254                            if (getDB().isSupportsInlineDistinct()) {
22255                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22256                            }
22257                            else {
22258                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22259                            }
22260                    }
22261    
22262                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22263                                    JournalArticle.class.getName(),
22264                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22265    
22266                    SQLQuery q = session.createSQLQuery(sql);
22267    
22268                    q.setFirstResult(0);
22269                    q.setMaxResults(2);
22270    
22271                    if (getDB().isSupportsInlineDistinct()) {
22272                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22273                    }
22274                    else {
22275                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22276                    }
22277    
22278                    QueryPos qPos = QueryPos.getInstance(q);
22279    
22280                    qPos.add(groupId);
22281    
22282                    qPos.add(classNameId);
22283    
22284                    qPos.add(classPK);
22285    
22286                    if (orderByComparator != null) {
22287                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22288    
22289                            for (Object value : values) {
22290                                    qPos.add(value);
22291                            }
22292                    }
22293    
22294                    List<JournalArticle> list = q.list();
22295    
22296                    if (list.size() == 2) {
22297                            return list.get(1);
22298                    }
22299                    else {
22300                            return null;
22301                    }
22302            }
22303    
22304            /**
22305             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
22306             *
22307             * @param groupId the group ID
22308             * @param classNameId the class name ID
22309             * @param classPK the class p k
22310             * @throws SystemException if a system exception occurred
22311             */
22312            @Override
22313            public void removeByG_C_C(long groupId, long classNameId, long classPK)
22314                    throws SystemException {
22315                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
22316                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22317                            remove(journalArticle);
22318                    }
22319            }
22320    
22321            /**
22322             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
22323             *
22324             * @param groupId the group ID
22325             * @param classNameId the class name ID
22326             * @param classPK the class p k
22327             * @return the number of matching journal articles
22328             * @throws SystemException if a system exception occurred
22329             */
22330            @Override
22331            public int countByG_C_C(long groupId, long classNameId, long classPK)
22332                    throws SystemException {
22333                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
22334    
22335                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
22336    
22337                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22338                                    this);
22339    
22340                    if (count == null) {
22341                            StringBundler query = new StringBundler(4);
22342    
22343                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22344    
22345                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22346    
22347                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22348    
22349                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22350    
22351                            String sql = query.toString();
22352    
22353                            Session session = null;
22354    
22355                            try {
22356                                    session = openSession();
22357    
22358                                    Query q = session.createQuery(sql);
22359    
22360                                    QueryPos qPos = QueryPos.getInstance(q);
22361    
22362                                    qPos.add(groupId);
22363    
22364                                    qPos.add(classNameId);
22365    
22366                                    qPos.add(classPK);
22367    
22368                                    count = (Long)q.uniqueResult();
22369    
22370                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22371                            }
22372                            catch (Exception e) {
22373                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22374    
22375                                    throw processException(e);
22376                            }
22377                            finally {
22378                                    closeSession(session);
22379                            }
22380                    }
22381    
22382                    return count.intValue();
22383            }
22384    
22385            /**
22386             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
22387             *
22388             * @param groupId the group ID
22389             * @param classNameId the class name ID
22390             * @param classPK the class p k
22391             * @return the number of matching journal articles that the user has permission to view
22392             * @throws SystemException if a system exception occurred
22393             */
22394            @Override
22395            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
22396                    throws SystemException {
22397                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22398                            return countByG_C_C(groupId, classNameId, classPK);
22399                    }
22400    
22401                    StringBundler query = new StringBundler(4);
22402    
22403                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22404    
22405                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22406    
22407                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22408    
22409                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22410    
22411                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22412                                    JournalArticle.class.getName(),
22413                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22414    
22415                    Session session = null;
22416    
22417                    try {
22418                            session = openSession();
22419    
22420                            SQLQuery q = session.createSQLQuery(sql);
22421    
22422                            q.addScalar(COUNT_COLUMN_NAME,
22423                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22424    
22425                            QueryPos qPos = QueryPos.getInstance(q);
22426    
22427                            qPos.add(groupId);
22428    
22429                            qPos.add(classNameId);
22430    
22431                            qPos.add(classPK);
22432    
22433                            Long count = (Long)q.uniqueResult();
22434    
22435                            return count.intValue();
22436                    }
22437                    catch (Exception e) {
22438                            throw processException(e);
22439                    }
22440                    finally {
22441                            closeSession(session);
22442                    }
22443            }
22444    
22445            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
22446            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22447            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
22448            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22449                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22450                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
22451                            new String[] {
22452                                    Long.class.getName(), Long.class.getName(),
22453                                    String.class.getName()
22454                            },
22455                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22456                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22457                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
22458            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22459                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22460                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
22461                            new String[] {
22462                                    Long.class.getName(), Long.class.getName(),
22463                                    String.class.getName()
22464                            });
22465    
22466            /**
22467             * 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.
22468             *
22469             * @param groupId the group ID
22470             * @param classNameId the class name ID
22471             * @param structureId the structure ID
22472             * @return the matching journal article
22473             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22474             * @throws SystemException if a system exception occurred
22475             */
22476            @Override
22477            public JournalArticle findByG_C_S(long groupId, long classNameId,
22478                    String structureId) throws NoSuchArticleException, SystemException {
22479                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
22480                                    structureId);
22481    
22482                    if (journalArticle == null) {
22483                            StringBundler msg = new StringBundler(8);
22484    
22485                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22486    
22487                            msg.append("groupId=");
22488                            msg.append(groupId);
22489    
22490                            msg.append(", classNameId=");
22491                            msg.append(classNameId);
22492    
22493                            msg.append(", structureId=");
22494                            msg.append(structureId);
22495    
22496                            msg.append(StringPool.CLOSE_CURLY_BRACE);
22497    
22498                            if (_log.isWarnEnabled()) {
22499                                    _log.warn(msg.toString());
22500                            }
22501    
22502                            throw new NoSuchArticleException(msg.toString());
22503                    }
22504    
22505                    return journalArticle;
22506            }
22507    
22508            /**
22509             * 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.
22510             *
22511             * @param groupId the group ID
22512             * @param classNameId the class name ID
22513             * @param structureId the structure ID
22514             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
22515             * @throws SystemException if a system exception occurred
22516             */
22517            @Override
22518            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
22519                    String structureId) throws SystemException {
22520                    return fetchByG_C_S(groupId, classNameId, structureId, true);
22521            }
22522    
22523            /**
22524             * 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.
22525             *
22526             * @param groupId the group ID
22527             * @param classNameId the class name ID
22528             * @param structureId the structure ID
22529             * @param retrieveFromCache whether to use the finder cache
22530             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
22531             * @throws SystemException if a system exception occurred
22532             */
22533            @Override
22534            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
22535                    String structureId, boolean retrieveFromCache)
22536                    throws SystemException {
22537                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
22538    
22539                    Object result = null;
22540    
22541                    if (retrieveFromCache) {
22542                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
22543                                            finderArgs, this);
22544                    }
22545    
22546                    if (result instanceof JournalArticle) {
22547                            JournalArticle journalArticle = (JournalArticle)result;
22548    
22549                            if ((groupId != journalArticle.getGroupId()) ||
22550                                            (classNameId != journalArticle.getClassNameId()) ||
22551                                            !Validator.equals(structureId,
22552                                                    journalArticle.getStructureId())) {
22553                                    result = null;
22554                            }
22555                    }
22556    
22557                    if (result == null) {
22558                            StringBundler query = new StringBundler(5);
22559    
22560                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22561    
22562                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
22563    
22564                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
22565    
22566                            boolean bindStructureId = false;
22567    
22568                            if (structureId == null) {
22569                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
22570                            }
22571                            else if (structureId.equals(StringPool.BLANK)) {
22572                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
22573                            }
22574                            else {
22575                                    bindStructureId = true;
22576    
22577                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
22578                            }
22579    
22580                            String sql = query.toString();
22581    
22582                            Session session = null;
22583    
22584                            try {
22585                                    session = openSession();
22586    
22587                                    Query q = session.createQuery(sql);
22588    
22589                                    QueryPos qPos = QueryPos.getInstance(q);
22590    
22591                                    qPos.add(groupId);
22592    
22593                                    qPos.add(classNameId);
22594    
22595                                    if (bindStructureId) {
22596                                            qPos.add(structureId);
22597                                    }
22598    
22599                                    List<JournalArticle> list = q.list();
22600    
22601                                    if (list.isEmpty()) {
22602                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
22603                                                    finderArgs, list);
22604                                    }
22605                                    else {
22606                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
22607                                                    _log.warn(
22608                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
22609                                                            StringUtil.merge(finderArgs) +
22610                                                            ") 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.");
22611                                            }
22612    
22613                                            JournalArticle journalArticle = list.get(0);
22614    
22615                                            result = journalArticle;
22616    
22617                                            cacheResult(journalArticle);
22618    
22619                                            if ((journalArticle.getGroupId() != groupId) ||
22620                                                            (journalArticle.getClassNameId() != classNameId) ||
22621                                                            (journalArticle.getStructureId() == null) ||
22622                                                            !journalArticle.getStructureId().equals(structureId)) {
22623                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
22624                                                            finderArgs, journalArticle);
22625                                            }
22626                                    }
22627                            }
22628                            catch (Exception e) {
22629                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
22630                                            finderArgs);
22631    
22632                                    throw processException(e);
22633                            }
22634                            finally {
22635                                    closeSession(session);
22636                            }
22637                    }
22638    
22639                    if (result instanceof List<?>) {
22640                            return null;
22641                    }
22642                    else {
22643                            return (JournalArticle)result;
22644                    }
22645            }
22646    
22647            /**
22648             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
22649             *
22650             * @param groupId the group ID
22651             * @param classNameId the class name ID
22652             * @param structureId the structure ID
22653             * @return the journal article that was removed
22654             * @throws SystemException if a system exception occurred
22655             */
22656            @Override
22657            public JournalArticle removeByG_C_S(long groupId, long classNameId,
22658                    String structureId) throws NoSuchArticleException, SystemException {
22659                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
22660                                    structureId);
22661    
22662                    return remove(journalArticle);
22663            }
22664    
22665            /**
22666             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
22667             *
22668             * @param groupId the group ID
22669             * @param classNameId the class name ID
22670             * @param structureId the structure ID
22671             * @return the number of matching journal articles
22672             * @throws SystemException if a system exception occurred
22673             */
22674            @Override
22675            public int countByG_C_S(long groupId, long classNameId, String structureId)
22676                    throws SystemException {
22677                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
22678    
22679                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
22680    
22681                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22682                                    this);
22683    
22684                    if (count == null) {
22685                            StringBundler query = new StringBundler(4);
22686    
22687                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22688    
22689                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
22690    
22691                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
22692    
22693                            boolean bindStructureId = false;
22694    
22695                            if (structureId == null) {
22696                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
22697                            }
22698                            else if (structureId.equals(StringPool.BLANK)) {
22699                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
22700                            }
22701                            else {
22702                                    bindStructureId = true;
22703    
22704                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
22705                            }
22706    
22707                            String sql = query.toString();
22708    
22709                            Session session = null;
22710    
22711                            try {
22712                                    session = openSession();
22713    
22714                                    Query q = session.createQuery(sql);
22715    
22716                                    QueryPos qPos = QueryPos.getInstance(q);
22717    
22718                                    qPos.add(groupId);
22719    
22720                                    qPos.add(classNameId);
22721    
22722                                    if (bindStructureId) {
22723                                            qPos.add(structureId);
22724                                    }
22725    
22726                                    count = (Long)q.uniqueResult();
22727    
22728                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22729                            }
22730                            catch (Exception e) {
22731                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22732    
22733                                    throw processException(e);
22734                            }
22735                            finally {
22736                                    closeSession(session);
22737                            }
22738                    }
22739    
22740                    return count.intValue();
22741            }
22742    
22743            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
22744            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22745            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
22746            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
22747            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
22748            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22749                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22750                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22751                            "findByG_C_T",
22752                            new String[] {
22753                                    Long.class.getName(), Long.class.getName(),
22754                                    String.class.getName(),
22755                                    
22756                            Integer.class.getName(), Integer.class.getName(),
22757                                    OrderByComparator.class.getName()
22758                            });
22759            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22760                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22761                            JournalArticleImpl.class,
22762                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
22763                            new String[] {
22764                                    Long.class.getName(), Long.class.getName(),
22765                                    String.class.getName()
22766                            },
22767                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22768                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22769                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
22770                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22771                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22772            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22773                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22774                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
22775                            new String[] {
22776                                    Long.class.getName(), Long.class.getName(),
22777                                    String.class.getName()
22778                            });
22779    
22780            /**
22781             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22782             *
22783             * @param groupId the group ID
22784             * @param classNameId the class name ID
22785             * @param templateId the template ID
22786             * @return the matching journal articles
22787             * @throws SystemException if a system exception occurred
22788             */
22789            @Override
22790            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22791                    String templateId) throws SystemException {
22792                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
22793                            QueryUtil.ALL_POS, null);
22794            }
22795    
22796            /**
22797             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22798             *
22799             * <p>
22800             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22801             * </p>
22802             *
22803             * @param groupId the group ID
22804             * @param classNameId the class name ID
22805             * @param templateId the template ID
22806             * @param start the lower bound of the range of journal articles
22807             * @param end the upper bound of the range of journal articles (not inclusive)
22808             * @return the range of matching journal articles
22809             * @throws SystemException if a system exception occurred
22810             */
22811            @Override
22812            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22813                    String templateId, int start, int end) throws SystemException {
22814                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
22815            }
22816    
22817            /**
22818             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22819             *
22820             * <p>
22821             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22822             * </p>
22823             *
22824             * @param groupId the group ID
22825             * @param classNameId the class name ID
22826             * @param templateId the template ID
22827             * @param start the lower bound of the range of journal articles
22828             * @param end the upper bound of the range of journal articles (not inclusive)
22829             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22830             * @return the ordered range of matching journal articles
22831             * @throws SystemException if a system exception occurred
22832             */
22833            @Override
22834            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22835                    String templateId, int start, int end,
22836                    OrderByComparator orderByComparator) throws SystemException {
22837                    boolean pagination = true;
22838                    FinderPath finderPath = null;
22839                    Object[] finderArgs = null;
22840    
22841                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22842                                    (orderByComparator == null)) {
22843                            pagination = false;
22844                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
22845                            finderArgs = new Object[] { groupId, classNameId, templateId };
22846                    }
22847                    else {
22848                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
22849                            finderArgs = new Object[] {
22850                                            groupId, classNameId, templateId,
22851                                            
22852                                            start, end, orderByComparator
22853                                    };
22854                    }
22855    
22856                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22857                                    finderArgs, this);
22858    
22859                    if ((list != null) && !list.isEmpty()) {
22860                            for (JournalArticle journalArticle : list) {
22861                                    if ((groupId != journalArticle.getGroupId()) ||
22862                                                    (classNameId != journalArticle.getClassNameId()) ||
22863                                                    !Validator.equals(templateId,
22864                                                            journalArticle.getTemplateId())) {
22865                                            list = null;
22866    
22867                                            break;
22868                                    }
22869                            }
22870                    }
22871    
22872                    if (list == null) {
22873                            StringBundler query = null;
22874    
22875                            if (orderByComparator != null) {
22876                                    query = new StringBundler(5 +
22877                                                    (orderByComparator.getOrderByFields().length * 3));
22878                            }
22879                            else {
22880                                    query = new StringBundler(5);
22881                            }
22882    
22883                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22884    
22885                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22886    
22887                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22888    
22889                            boolean bindTemplateId = false;
22890    
22891                            if (templateId == null) {
22892                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22893                            }
22894                            else if (templateId.equals(StringPool.BLANK)) {
22895                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22896                            }
22897                            else {
22898                                    bindTemplateId = true;
22899    
22900                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22901                            }
22902    
22903                            if (orderByComparator != null) {
22904                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22905                                            orderByComparator);
22906                            }
22907                            else
22908                             if (pagination) {
22909                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22910                            }
22911    
22912                            String sql = query.toString();
22913    
22914                            Session session = null;
22915    
22916                            try {
22917                                    session = openSession();
22918    
22919                                    Query q = session.createQuery(sql);
22920    
22921                                    QueryPos qPos = QueryPos.getInstance(q);
22922    
22923                                    qPos.add(groupId);
22924    
22925                                    qPos.add(classNameId);
22926    
22927                                    if (bindTemplateId) {
22928                                            qPos.add(templateId);
22929                                    }
22930    
22931                                    if (!pagination) {
22932                                            list = (List<JournalArticle>)QueryUtil.list(q,
22933                                                            getDialect(), start, end, false);
22934    
22935                                            Collections.sort(list);
22936    
22937                                            list = new UnmodifiableList<JournalArticle>(list);
22938                                    }
22939                                    else {
22940                                            list = (List<JournalArticle>)QueryUtil.list(q,
22941                                                            getDialect(), start, end);
22942                                    }
22943    
22944                                    cacheResult(list);
22945    
22946                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22947                            }
22948                            catch (Exception e) {
22949                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22950    
22951                                    throw processException(e);
22952                            }
22953                            finally {
22954                                    closeSession(session);
22955                            }
22956                    }
22957    
22958                    return list;
22959            }
22960    
22961            /**
22962             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22963             *
22964             * @param groupId the group ID
22965             * @param classNameId the class name ID
22966             * @param templateId the template ID
22967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22968             * @return the first matching journal article
22969             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22970             * @throws SystemException if a system exception occurred
22971             */
22972            @Override
22973            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
22974                    String templateId, OrderByComparator orderByComparator)
22975                    throws NoSuchArticleException, SystemException {
22976                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
22977                                    classNameId, templateId, orderByComparator);
22978    
22979                    if (journalArticle != null) {
22980                            return journalArticle;
22981                    }
22982    
22983                    StringBundler msg = new StringBundler(8);
22984    
22985                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22986    
22987                    msg.append("groupId=");
22988                    msg.append(groupId);
22989    
22990                    msg.append(", classNameId=");
22991                    msg.append(classNameId);
22992    
22993                    msg.append(", templateId=");
22994                    msg.append(templateId);
22995    
22996                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22997    
22998                    throw new NoSuchArticleException(msg.toString());
22999            }
23000    
23001            /**
23002             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23003             *
23004             * @param groupId the group ID
23005             * @param classNameId the class name ID
23006             * @param templateId the template ID
23007             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23008             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23009             * @throws SystemException if a system exception occurred
23010             */
23011            @Override
23012            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
23013                    String templateId, OrderByComparator orderByComparator)
23014                    throws SystemException {
23015                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
23016                                    templateId, 0, 1, orderByComparator);
23017    
23018                    if (!list.isEmpty()) {
23019                            return list.get(0);
23020                    }
23021    
23022                    return null;
23023            }
23024    
23025            /**
23026             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23027             *
23028             * @param groupId the group ID
23029             * @param classNameId the class name ID
23030             * @param templateId the template ID
23031             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23032             * @return the last matching journal article
23033             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23034             * @throws SystemException if a system exception occurred
23035             */
23036            @Override
23037            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
23038                    String templateId, OrderByComparator orderByComparator)
23039                    throws NoSuchArticleException, SystemException {
23040                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
23041                                    templateId, orderByComparator);
23042    
23043                    if (journalArticle != null) {
23044                            return journalArticle;
23045                    }
23046    
23047                    StringBundler msg = new StringBundler(8);
23048    
23049                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23050    
23051                    msg.append("groupId=");
23052                    msg.append(groupId);
23053    
23054                    msg.append(", classNameId=");
23055                    msg.append(classNameId);
23056    
23057                    msg.append(", templateId=");
23058                    msg.append(templateId);
23059    
23060                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23061    
23062                    throw new NoSuchArticleException(msg.toString());
23063            }
23064    
23065            /**
23066             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23067             *
23068             * @param groupId the group ID
23069             * @param classNameId the class name ID
23070             * @param templateId the template ID
23071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23072             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23073             * @throws SystemException if a system exception occurred
23074             */
23075            @Override
23076            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
23077                    String templateId, OrderByComparator orderByComparator)
23078                    throws SystemException {
23079                    int count = countByG_C_T(groupId, classNameId, templateId);
23080    
23081                    if (count == 0) {
23082                            return null;
23083                    }
23084    
23085                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
23086                                    templateId, count - 1, count, orderByComparator);
23087    
23088                    if (!list.isEmpty()) {
23089                            return list.get(0);
23090                    }
23091    
23092                    return null;
23093            }
23094    
23095            /**
23096             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23097             *
23098             * @param id the primary key of the current journal article
23099             * @param groupId the group ID
23100             * @param classNameId the class name ID
23101             * @param templateId the template ID
23102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23103             * @return the previous, current, and next journal article
23104             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23105             * @throws SystemException if a system exception occurred
23106             */
23107            @Override
23108            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
23109                    long classNameId, String templateId, OrderByComparator orderByComparator)
23110                    throws NoSuchArticleException, SystemException {
23111                    JournalArticle journalArticle = findByPrimaryKey(id);
23112    
23113                    Session session = null;
23114    
23115                    try {
23116                            session = openSession();
23117    
23118                            JournalArticle[] array = new JournalArticleImpl[3];
23119    
23120                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
23121                                            classNameId, templateId, orderByComparator, true);
23122    
23123                            array[1] = journalArticle;
23124    
23125                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
23126                                            classNameId, templateId, orderByComparator, false);
23127    
23128                            return array;
23129                    }
23130                    catch (Exception e) {
23131                            throw processException(e);
23132                    }
23133                    finally {
23134                            closeSession(session);
23135                    }
23136            }
23137    
23138            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
23139                    JournalArticle journalArticle, long groupId, long classNameId,
23140                    String templateId, OrderByComparator orderByComparator, boolean previous) {
23141                    StringBundler query = null;
23142    
23143                    if (orderByComparator != null) {
23144                            query = new StringBundler(6 +
23145                                            (orderByComparator.getOrderByFields().length * 6));
23146                    }
23147                    else {
23148                            query = new StringBundler(3);
23149                    }
23150    
23151                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23152    
23153                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23154    
23155                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23156    
23157                    boolean bindTemplateId = false;
23158    
23159                    if (templateId == null) {
23160                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23161                    }
23162                    else if (templateId.equals(StringPool.BLANK)) {
23163                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23164                    }
23165                    else {
23166                            bindTemplateId = true;
23167    
23168                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23169                    }
23170    
23171                    if (orderByComparator != null) {
23172                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23173    
23174                            if (orderByConditionFields.length > 0) {
23175                                    query.append(WHERE_AND);
23176                            }
23177    
23178                            for (int i = 0; i < orderByConditionFields.length; i++) {
23179                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23180                                    query.append(orderByConditionFields[i]);
23181    
23182                                    if ((i + 1) < orderByConditionFields.length) {
23183                                            if (orderByComparator.isAscending() ^ previous) {
23184                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23185                                            }
23186                                            else {
23187                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23188                                            }
23189                                    }
23190                                    else {
23191                                            if (orderByComparator.isAscending() ^ previous) {
23192                                                    query.append(WHERE_GREATER_THAN);
23193                                            }
23194                                            else {
23195                                                    query.append(WHERE_LESSER_THAN);
23196                                            }
23197                                    }
23198                            }
23199    
23200                            query.append(ORDER_BY_CLAUSE);
23201    
23202                            String[] orderByFields = orderByComparator.getOrderByFields();
23203    
23204                            for (int i = 0; i < orderByFields.length; i++) {
23205                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23206                                    query.append(orderByFields[i]);
23207    
23208                                    if ((i + 1) < orderByFields.length) {
23209                                            if (orderByComparator.isAscending() ^ previous) {
23210                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23211                                            }
23212                                            else {
23213                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23214                                            }
23215                                    }
23216                                    else {
23217                                            if (orderByComparator.isAscending() ^ previous) {
23218                                                    query.append(ORDER_BY_ASC);
23219                                            }
23220                                            else {
23221                                                    query.append(ORDER_BY_DESC);
23222                                            }
23223                                    }
23224                            }
23225                    }
23226                    else {
23227                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23228                    }
23229    
23230                    String sql = query.toString();
23231    
23232                    Query q = session.createQuery(sql);
23233    
23234                    q.setFirstResult(0);
23235                    q.setMaxResults(2);
23236    
23237                    QueryPos qPos = QueryPos.getInstance(q);
23238    
23239                    qPos.add(groupId);
23240    
23241                    qPos.add(classNameId);
23242    
23243                    if (bindTemplateId) {
23244                            qPos.add(templateId);
23245                    }
23246    
23247                    if (orderByComparator != null) {
23248                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23249    
23250                            for (Object value : values) {
23251                                    qPos.add(value);
23252                            }
23253                    }
23254    
23255                    List<JournalArticle> list = q.list();
23256    
23257                    if (list.size() == 2) {
23258                            return list.get(1);
23259                    }
23260                    else {
23261                            return null;
23262                    }
23263            }
23264    
23265            /**
23266             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23267             *
23268             * @param groupId the group ID
23269             * @param classNameId the class name ID
23270             * @param templateId the template ID
23271             * @return the matching journal articles that the user has permission to view
23272             * @throws SystemException if a system exception occurred
23273             */
23274            @Override
23275            public List<JournalArticle> filterFindByG_C_T(long groupId,
23276                    long classNameId, String templateId) throws SystemException {
23277                    return filterFindByG_C_T(groupId, classNameId, templateId,
23278                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23279            }
23280    
23281            /**
23282             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23283             *
23284             * <p>
23285             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23286             * </p>
23287             *
23288             * @param groupId the group ID
23289             * @param classNameId the class name ID
23290             * @param templateId the template ID
23291             * @param start the lower bound of the range of journal articles
23292             * @param end the upper bound of the range of journal articles (not inclusive)
23293             * @return the range of matching journal articles that the user has permission to view
23294             * @throws SystemException if a system exception occurred
23295             */
23296            @Override
23297            public List<JournalArticle> filterFindByG_C_T(long groupId,
23298                    long classNameId, String templateId, int start, int end)
23299                    throws SystemException {
23300                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
23301                            null);
23302            }
23303    
23304            /**
23305             * 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;.
23306             *
23307             * <p>
23308             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23309             * </p>
23310             *
23311             * @param groupId the group ID
23312             * @param classNameId the class name ID
23313             * @param templateId the template ID
23314             * @param start the lower bound of the range of journal articles
23315             * @param end the upper bound of the range of journal articles (not inclusive)
23316             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23317             * @return the ordered range of matching journal articles that the user has permission to view
23318             * @throws SystemException if a system exception occurred
23319             */
23320            @Override
23321            public List<JournalArticle> filterFindByG_C_T(long groupId,
23322                    long classNameId, String templateId, int start, int end,
23323                    OrderByComparator orderByComparator) throws SystemException {
23324                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23325                            return findByG_C_T(groupId, classNameId, templateId, start, end,
23326                                    orderByComparator);
23327                    }
23328    
23329                    StringBundler query = null;
23330    
23331                    if (orderByComparator != null) {
23332                            query = new StringBundler(5 +
23333                                            (orderByComparator.getOrderByFields().length * 3));
23334                    }
23335                    else {
23336                            query = new StringBundler(5);
23337                    }
23338    
23339                    if (getDB().isSupportsInlineDistinct()) {
23340                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23341                    }
23342                    else {
23343                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23344                    }
23345    
23346                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23347    
23348                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23349    
23350                    boolean bindTemplateId = false;
23351    
23352                    if (templateId == null) {
23353                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23354                    }
23355                    else if (templateId.equals(StringPool.BLANK)) {
23356                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23357                    }
23358                    else {
23359                            bindTemplateId = true;
23360    
23361                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23362                    }
23363    
23364                    if (!getDB().isSupportsInlineDistinct()) {
23365                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23366                    }
23367    
23368                    if (orderByComparator != null) {
23369                            if (getDB().isSupportsInlineDistinct()) {
23370                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23371                                            orderByComparator, true);
23372                            }
23373                            else {
23374                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23375                                            orderByComparator, true);
23376                            }
23377                    }
23378                    else {
23379                            if (getDB().isSupportsInlineDistinct()) {
23380                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23381                            }
23382                            else {
23383                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23384                            }
23385                    }
23386    
23387                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23388                                    JournalArticle.class.getName(),
23389                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23390    
23391                    Session session = null;
23392    
23393                    try {
23394                            session = openSession();
23395    
23396                            SQLQuery q = session.createSQLQuery(sql);
23397    
23398                            if (getDB().isSupportsInlineDistinct()) {
23399                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23400                            }
23401                            else {
23402                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23403                            }
23404    
23405                            QueryPos qPos = QueryPos.getInstance(q);
23406    
23407                            qPos.add(groupId);
23408    
23409                            qPos.add(classNameId);
23410    
23411                            if (bindTemplateId) {
23412                                    qPos.add(templateId);
23413                            }
23414    
23415                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23416                                    end);
23417                    }
23418                    catch (Exception e) {
23419                            throw processException(e);
23420                    }
23421                    finally {
23422                            closeSession(session);
23423                    }
23424            }
23425    
23426            /**
23427             * 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;.
23428             *
23429             * @param id the primary key of the current journal article
23430             * @param groupId the group ID
23431             * @param classNameId the class name ID
23432             * @param templateId the template ID
23433             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23434             * @return the previous, current, and next journal article
23435             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23436             * @throws SystemException if a system exception occurred
23437             */
23438            @Override
23439            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
23440                    long groupId, long classNameId, String templateId,
23441                    OrderByComparator orderByComparator)
23442                    throws NoSuchArticleException, SystemException {
23443                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23444                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
23445                                    templateId, orderByComparator);
23446                    }
23447    
23448                    JournalArticle journalArticle = findByPrimaryKey(id);
23449    
23450                    Session session = null;
23451    
23452                    try {
23453                            session = openSession();
23454    
23455                            JournalArticle[] array = new JournalArticleImpl[3];
23456    
23457                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
23458                                            groupId, classNameId, templateId, orderByComparator, true);
23459    
23460                            array[1] = journalArticle;
23461    
23462                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
23463                                            groupId, classNameId, templateId, orderByComparator, false);
23464    
23465                            return array;
23466                    }
23467                    catch (Exception e) {
23468                            throw processException(e);
23469                    }
23470                    finally {
23471                            closeSession(session);
23472                    }
23473            }
23474    
23475            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
23476                    JournalArticle journalArticle, long groupId, long classNameId,
23477                    String templateId, OrderByComparator orderByComparator, boolean previous) {
23478                    StringBundler query = null;
23479    
23480                    if (orderByComparator != null) {
23481                            query = new StringBundler(6 +
23482                                            (orderByComparator.getOrderByFields().length * 6));
23483                    }
23484                    else {
23485                            query = new StringBundler(3);
23486                    }
23487    
23488                    if (getDB().isSupportsInlineDistinct()) {
23489                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23490                    }
23491                    else {
23492                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23493                    }
23494    
23495                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23496    
23497                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23498    
23499                    boolean bindTemplateId = false;
23500    
23501                    if (templateId == null) {
23502                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23503                    }
23504                    else if (templateId.equals(StringPool.BLANK)) {
23505                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23506                    }
23507                    else {
23508                            bindTemplateId = true;
23509    
23510                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23511                    }
23512    
23513                    if (!getDB().isSupportsInlineDistinct()) {
23514                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23515                    }
23516    
23517                    if (orderByComparator != null) {
23518                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23519    
23520                            if (orderByConditionFields.length > 0) {
23521                                    query.append(WHERE_AND);
23522                            }
23523    
23524                            for (int i = 0; i < orderByConditionFields.length; i++) {
23525                                    if (getDB().isSupportsInlineDistinct()) {
23526                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23527                                    }
23528                                    else {
23529                                            query.append(_ORDER_BY_ENTITY_TABLE);
23530                                    }
23531    
23532                                    query.append(orderByConditionFields[i]);
23533    
23534                                    if ((i + 1) < orderByConditionFields.length) {
23535                                            if (orderByComparator.isAscending() ^ previous) {
23536                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23537                                            }
23538                                            else {
23539                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23540                                            }
23541                                    }
23542                                    else {
23543                                            if (orderByComparator.isAscending() ^ previous) {
23544                                                    query.append(WHERE_GREATER_THAN);
23545                                            }
23546                                            else {
23547                                                    query.append(WHERE_LESSER_THAN);
23548                                            }
23549                                    }
23550                            }
23551    
23552                            query.append(ORDER_BY_CLAUSE);
23553    
23554                            String[] orderByFields = orderByComparator.getOrderByFields();
23555    
23556                            for (int i = 0; i < orderByFields.length; i++) {
23557                                    if (getDB().isSupportsInlineDistinct()) {
23558                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23559                                    }
23560                                    else {
23561                                            query.append(_ORDER_BY_ENTITY_TABLE);
23562                                    }
23563    
23564                                    query.append(orderByFields[i]);
23565    
23566                                    if ((i + 1) < orderByFields.length) {
23567                                            if (orderByComparator.isAscending() ^ previous) {
23568                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23569                                            }
23570                                            else {
23571                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23572                                            }
23573                                    }
23574                                    else {
23575                                            if (orderByComparator.isAscending() ^ previous) {
23576                                                    query.append(ORDER_BY_ASC);
23577                                            }
23578                                            else {
23579                                                    query.append(ORDER_BY_DESC);
23580                                            }
23581                                    }
23582                            }
23583                    }
23584                    else {
23585                            if (getDB().isSupportsInlineDistinct()) {
23586                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23587                            }
23588                            else {
23589                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23590                            }
23591                    }
23592    
23593                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23594                                    JournalArticle.class.getName(),
23595                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23596    
23597                    SQLQuery q = session.createSQLQuery(sql);
23598    
23599                    q.setFirstResult(0);
23600                    q.setMaxResults(2);
23601    
23602                    if (getDB().isSupportsInlineDistinct()) {
23603                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23604                    }
23605                    else {
23606                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23607                    }
23608    
23609                    QueryPos qPos = QueryPos.getInstance(q);
23610    
23611                    qPos.add(groupId);
23612    
23613                    qPos.add(classNameId);
23614    
23615                    if (bindTemplateId) {
23616                            qPos.add(templateId);
23617                    }
23618    
23619                    if (orderByComparator != null) {
23620                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23621    
23622                            for (Object value : values) {
23623                                    qPos.add(value);
23624                            }
23625                    }
23626    
23627                    List<JournalArticle> list = q.list();
23628    
23629                    if (list.size() == 2) {
23630                            return list.get(1);
23631                    }
23632                    else {
23633                            return null;
23634                    }
23635            }
23636    
23637            /**
23638             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
23639             *
23640             * @param groupId the group ID
23641             * @param classNameId the class name ID
23642             * @param templateId the template ID
23643             * @throws SystemException if a system exception occurred
23644             */
23645            @Override
23646            public void removeByG_C_T(long groupId, long classNameId, String templateId)
23647                    throws SystemException {
23648                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
23649                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23650                            remove(journalArticle);
23651                    }
23652            }
23653    
23654            /**
23655             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23656             *
23657             * @param groupId the group ID
23658             * @param classNameId the class name ID
23659             * @param templateId the template ID
23660             * @return the number of matching journal articles
23661             * @throws SystemException if a system exception occurred
23662             */
23663            @Override
23664            public int countByG_C_T(long groupId, long classNameId, String templateId)
23665                    throws SystemException {
23666                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
23667    
23668                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
23669    
23670                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23671                                    this);
23672    
23673                    if (count == null) {
23674                            StringBundler query = new StringBundler(4);
23675    
23676                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23677    
23678                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23679    
23680                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23681    
23682                            boolean bindTemplateId = false;
23683    
23684                            if (templateId == null) {
23685                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23686                            }
23687                            else if (templateId.equals(StringPool.BLANK)) {
23688                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23689                            }
23690                            else {
23691                                    bindTemplateId = true;
23692    
23693                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23694                            }
23695    
23696                            String sql = query.toString();
23697    
23698                            Session session = null;
23699    
23700                            try {
23701                                    session = openSession();
23702    
23703                                    Query q = session.createQuery(sql);
23704    
23705                                    QueryPos qPos = QueryPos.getInstance(q);
23706    
23707                                    qPos.add(groupId);
23708    
23709                                    qPos.add(classNameId);
23710    
23711                                    if (bindTemplateId) {
23712                                            qPos.add(templateId);
23713                                    }
23714    
23715                                    count = (Long)q.uniqueResult();
23716    
23717                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23718                            }
23719                            catch (Exception e) {
23720                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23721    
23722                                    throw processException(e);
23723                            }
23724                            finally {
23725                                    closeSession(session);
23726                            }
23727                    }
23728    
23729                    return count.intValue();
23730            }
23731    
23732            /**
23733             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23734             *
23735             * @param groupId the group ID
23736             * @param classNameId the class name ID
23737             * @param templateId the template ID
23738             * @return the number of matching journal articles that the user has permission to view
23739             * @throws SystemException if a system exception occurred
23740             */
23741            @Override
23742            public int filterCountByG_C_T(long groupId, long classNameId,
23743                    String templateId) throws SystemException {
23744                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23745                            return countByG_C_T(groupId, classNameId, templateId);
23746                    }
23747    
23748                    StringBundler query = new StringBundler(4);
23749    
23750                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23751    
23752                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23753    
23754                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23755    
23756                    boolean bindTemplateId = false;
23757    
23758                    if (templateId == null) {
23759                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23760                    }
23761                    else if (templateId.equals(StringPool.BLANK)) {
23762                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23763                    }
23764                    else {
23765                            bindTemplateId = true;
23766    
23767                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23768                    }
23769    
23770                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23771                                    JournalArticle.class.getName(),
23772                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23773    
23774                    Session session = null;
23775    
23776                    try {
23777                            session = openSession();
23778    
23779                            SQLQuery q = session.createSQLQuery(sql);
23780    
23781                            q.addScalar(COUNT_COLUMN_NAME,
23782                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23783    
23784                            QueryPos qPos = QueryPos.getInstance(q);
23785    
23786                            qPos.add(groupId);
23787    
23788                            qPos.add(classNameId);
23789    
23790                            if (bindTemplateId) {
23791                                    qPos.add(templateId);
23792                            }
23793    
23794                            Long count = (Long)q.uniqueResult();
23795    
23796                            return count.intValue();
23797                    }
23798                    catch (Exception e) {
23799                            throw processException(e);
23800                    }
23801                    finally {
23802                            closeSession(session);
23803                    }
23804            }
23805    
23806            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
23807            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
23808            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
23809            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
23810            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
23811            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23812                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23813                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23814                            "findByG_C_L",
23815                            new String[] {
23816                                    Long.class.getName(), Long.class.getName(),
23817                                    String.class.getName(),
23818                                    
23819                            Integer.class.getName(), Integer.class.getName(),
23820                                    OrderByComparator.class.getName()
23821                            });
23822            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23823                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23824                            JournalArticleImpl.class,
23825                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
23826                            new String[] {
23827                                    Long.class.getName(), Long.class.getName(),
23828                                    String.class.getName()
23829                            },
23830                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23831                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
23832                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
23833                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23834                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23835            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23836                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23837                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
23838                            new String[] {
23839                                    Long.class.getName(), Long.class.getName(),
23840                                    String.class.getName()
23841                            });
23842    
23843            /**
23844             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23845             *
23846             * @param groupId the group ID
23847             * @param classNameId the class name ID
23848             * @param layoutUuid the layout uuid
23849             * @return the matching journal articles
23850             * @throws SystemException if a system exception occurred
23851             */
23852            @Override
23853            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23854                    String layoutUuid) throws SystemException {
23855                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
23856                            QueryUtil.ALL_POS, null);
23857            }
23858    
23859            /**
23860             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23861             *
23862             * <p>
23863             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23864             * </p>
23865             *
23866             * @param groupId the group ID
23867             * @param classNameId the class name ID
23868             * @param layoutUuid the layout uuid
23869             * @param start the lower bound of the range of journal articles
23870             * @param end the upper bound of the range of journal articles (not inclusive)
23871             * @return the range of matching journal articles
23872             * @throws SystemException if a system exception occurred
23873             */
23874            @Override
23875            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23876                    String layoutUuid, int start, int end) throws SystemException {
23877                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
23878            }
23879    
23880            /**
23881             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23882             *
23883             * <p>
23884             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23885             * </p>
23886             *
23887             * @param groupId the group ID
23888             * @param classNameId the class name ID
23889             * @param layoutUuid the layout uuid
23890             * @param start the lower bound of the range of journal articles
23891             * @param end the upper bound of the range of journal articles (not inclusive)
23892             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23893             * @return the ordered range of matching journal articles
23894             * @throws SystemException if a system exception occurred
23895             */
23896            @Override
23897            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23898                    String layoutUuid, int start, int end,
23899                    OrderByComparator orderByComparator) throws SystemException {
23900                    boolean pagination = true;
23901                    FinderPath finderPath = null;
23902                    Object[] finderArgs = null;
23903    
23904                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23905                                    (orderByComparator == null)) {
23906                            pagination = false;
23907                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
23908                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
23909                    }
23910                    else {
23911                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
23912                            finderArgs = new Object[] {
23913                                            groupId, classNameId, layoutUuid,
23914                                            
23915                                            start, end, orderByComparator
23916                                    };
23917                    }
23918    
23919                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23920                                    finderArgs, this);
23921    
23922                    if ((list != null) && !list.isEmpty()) {
23923                            for (JournalArticle journalArticle : list) {
23924                                    if ((groupId != journalArticle.getGroupId()) ||
23925                                                    (classNameId != journalArticle.getClassNameId()) ||
23926                                                    !Validator.equals(layoutUuid,
23927                                                            journalArticle.getLayoutUuid())) {
23928                                            list = null;
23929    
23930                                            break;
23931                                    }
23932                            }
23933                    }
23934    
23935                    if (list == null) {
23936                            StringBundler query = null;
23937    
23938                            if (orderByComparator != null) {
23939                                    query = new StringBundler(5 +
23940                                                    (orderByComparator.getOrderByFields().length * 3));
23941                            }
23942                            else {
23943                                    query = new StringBundler(5);
23944                            }
23945    
23946                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23947    
23948                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23949    
23950                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23951    
23952                            boolean bindLayoutUuid = false;
23953    
23954                            if (layoutUuid == null) {
23955                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23956                            }
23957                            else if (layoutUuid.equals(StringPool.BLANK)) {
23958                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23959                            }
23960                            else {
23961                                    bindLayoutUuid = true;
23962    
23963                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23964                            }
23965    
23966                            if (orderByComparator != null) {
23967                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23968                                            orderByComparator);
23969                            }
23970                            else
23971                             if (pagination) {
23972                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23973                            }
23974    
23975                            String sql = query.toString();
23976    
23977                            Session session = null;
23978    
23979                            try {
23980                                    session = openSession();
23981    
23982                                    Query q = session.createQuery(sql);
23983    
23984                                    QueryPos qPos = QueryPos.getInstance(q);
23985    
23986                                    qPos.add(groupId);
23987    
23988                                    qPos.add(classNameId);
23989    
23990                                    if (bindLayoutUuid) {
23991                                            qPos.add(layoutUuid);
23992                                    }
23993    
23994                                    if (!pagination) {
23995                                            list = (List<JournalArticle>)QueryUtil.list(q,
23996                                                            getDialect(), start, end, false);
23997    
23998                                            Collections.sort(list);
23999    
24000                                            list = new UnmodifiableList<JournalArticle>(list);
24001                                    }
24002                                    else {
24003                                            list = (List<JournalArticle>)QueryUtil.list(q,
24004                                                            getDialect(), start, end);
24005                                    }
24006    
24007                                    cacheResult(list);
24008    
24009                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24010                            }
24011                            catch (Exception e) {
24012                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24013    
24014                                    throw processException(e);
24015                            }
24016                            finally {
24017                                    closeSession(session);
24018                            }
24019                    }
24020    
24021                    return list;
24022            }
24023    
24024            /**
24025             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24026             *
24027             * @param groupId the group ID
24028             * @param classNameId the class name ID
24029             * @param layoutUuid the layout uuid
24030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24031             * @return the first matching journal article
24032             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24033             * @throws SystemException if a system exception occurred
24034             */
24035            @Override
24036            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
24037                    String layoutUuid, OrderByComparator orderByComparator)
24038                    throws NoSuchArticleException, SystemException {
24039                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
24040                                    classNameId, layoutUuid, orderByComparator);
24041    
24042                    if (journalArticle != null) {
24043                            return journalArticle;
24044                    }
24045    
24046                    StringBundler msg = new StringBundler(8);
24047    
24048                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24049    
24050                    msg.append("groupId=");
24051                    msg.append(groupId);
24052    
24053                    msg.append(", classNameId=");
24054                    msg.append(classNameId);
24055    
24056                    msg.append(", layoutUuid=");
24057                    msg.append(layoutUuid);
24058    
24059                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24060    
24061                    throw new NoSuchArticleException(msg.toString());
24062            }
24063    
24064            /**
24065             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24066             *
24067             * @param groupId the group ID
24068             * @param classNameId the class name ID
24069             * @param layoutUuid the layout uuid
24070             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24071             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24072             * @throws SystemException if a system exception occurred
24073             */
24074            @Override
24075            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
24076                    String layoutUuid, OrderByComparator orderByComparator)
24077                    throws SystemException {
24078                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
24079                                    layoutUuid, 0, 1, orderByComparator);
24080    
24081                    if (!list.isEmpty()) {
24082                            return list.get(0);
24083                    }
24084    
24085                    return null;
24086            }
24087    
24088            /**
24089             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24090             *
24091             * @param groupId the group ID
24092             * @param classNameId the class name ID
24093             * @param layoutUuid the layout uuid
24094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24095             * @return the last matching journal article
24096             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24097             * @throws SystemException if a system exception occurred
24098             */
24099            @Override
24100            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
24101                    String layoutUuid, OrderByComparator orderByComparator)
24102                    throws NoSuchArticleException, SystemException {
24103                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
24104                                    layoutUuid, orderByComparator);
24105    
24106                    if (journalArticle != null) {
24107                            return journalArticle;
24108                    }
24109    
24110                    StringBundler msg = new StringBundler(8);
24111    
24112                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24113    
24114                    msg.append("groupId=");
24115                    msg.append(groupId);
24116    
24117                    msg.append(", classNameId=");
24118                    msg.append(classNameId);
24119    
24120                    msg.append(", layoutUuid=");
24121                    msg.append(layoutUuid);
24122    
24123                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24124    
24125                    throw new NoSuchArticleException(msg.toString());
24126            }
24127    
24128            /**
24129             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24130             *
24131             * @param groupId the group ID
24132             * @param classNameId the class name ID
24133             * @param layoutUuid the layout uuid
24134             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24135             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24136             * @throws SystemException if a system exception occurred
24137             */
24138            @Override
24139            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
24140                    String layoutUuid, OrderByComparator orderByComparator)
24141                    throws SystemException {
24142                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
24143    
24144                    if (count == 0) {
24145                            return null;
24146                    }
24147    
24148                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
24149                                    layoutUuid, count - 1, count, orderByComparator);
24150    
24151                    if (!list.isEmpty()) {
24152                            return list.get(0);
24153                    }
24154    
24155                    return null;
24156            }
24157    
24158            /**
24159             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24160             *
24161             * @param id the primary key of the current journal article
24162             * @param groupId the group ID
24163             * @param classNameId the class name ID
24164             * @param layoutUuid the layout uuid
24165             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24166             * @return the previous, current, and next journal article
24167             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24168             * @throws SystemException if a system exception occurred
24169             */
24170            @Override
24171            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
24172                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
24173                    throws NoSuchArticleException, SystemException {
24174                    JournalArticle journalArticle = findByPrimaryKey(id);
24175    
24176                    Session session = null;
24177    
24178                    try {
24179                            session = openSession();
24180    
24181                            JournalArticle[] array = new JournalArticleImpl[3];
24182    
24183                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
24184                                            classNameId, layoutUuid, orderByComparator, true);
24185    
24186                            array[1] = journalArticle;
24187    
24188                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
24189                                            classNameId, layoutUuid, orderByComparator, false);
24190    
24191                            return array;
24192                    }
24193                    catch (Exception e) {
24194                            throw processException(e);
24195                    }
24196                    finally {
24197                            closeSession(session);
24198                    }
24199            }
24200    
24201            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
24202                    JournalArticle journalArticle, long groupId, long classNameId,
24203                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
24204                    StringBundler query = null;
24205    
24206                    if (orderByComparator != null) {
24207                            query = new StringBundler(6 +
24208                                            (orderByComparator.getOrderByFields().length * 6));
24209                    }
24210                    else {
24211                            query = new StringBundler(3);
24212                    }
24213    
24214                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24215    
24216                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24217    
24218                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24219    
24220                    boolean bindLayoutUuid = false;
24221    
24222                    if (layoutUuid == null) {
24223                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24224                    }
24225                    else if (layoutUuid.equals(StringPool.BLANK)) {
24226                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24227                    }
24228                    else {
24229                            bindLayoutUuid = true;
24230    
24231                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24232                    }
24233    
24234                    if (orderByComparator != null) {
24235                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24236    
24237                            if (orderByConditionFields.length > 0) {
24238                                    query.append(WHERE_AND);
24239                            }
24240    
24241                            for (int i = 0; i < orderByConditionFields.length; i++) {
24242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24243                                    query.append(orderByConditionFields[i]);
24244    
24245                                    if ((i + 1) < orderByConditionFields.length) {
24246                                            if (orderByComparator.isAscending() ^ previous) {
24247                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24248                                            }
24249                                            else {
24250                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24251                                            }
24252                                    }
24253                                    else {
24254                                            if (orderByComparator.isAscending() ^ previous) {
24255                                                    query.append(WHERE_GREATER_THAN);
24256                                            }
24257                                            else {
24258                                                    query.append(WHERE_LESSER_THAN);
24259                                            }
24260                                    }
24261                            }
24262    
24263                            query.append(ORDER_BY_CLAUSE);
24264    
24265                            String[] orderByFields = orderByComparator.getOrderByFields();
24266    
24267                            for (int i = 0; i < orderByFields.length; i++) {
24268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24269                                    query.append(orderByFields[i]);
24270    
24271                                    if ((i + 1) < orderByFields.length) {
24272                                            if (orderByComparator.isAscending() ^ previous) {
24273                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24274                                            }
24275                                            else {
24276                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24277                                            }
24278                                    }
24279                                    else {
24280                                            if (orderByComparator.isAscending() ^ previous) {
24281                                                    query.append(ORDER_BY_ASC);
24282                                            }
24283                                            else {
24284                                                    query.append(ORDER_BY_DESC);
24285                                            }
24286                                    }
24287                            }
24288                    }
24289                    else {
24290                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24291                    }
24292    
24293                    String sql = query.toString();
24294    
24295                    Query q = session.createQuery(sql);
24296    
24297                    q.setFirstResult(0);
24298                    q.setMaxResults(2);
24299    
24300                    QueryPos qPos = QueryPos.getInstance(q);
24301    
24302                    qPos.add(groupId);
24303    
24304                    qPos.add(classNameId);
24305    
24306                    if (bindLayoutUuid) {
24307                            qPos.add(layoutUuid);
24308                    }
24309    
24310                    if (orderByComparator != null) {
24311                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24312    
24313                            for (Object value : values) {
24314                                    qPos.add(value);
24315                            }
24316                    }
24317    
24318                    List<JournalArticle> list = q.list();
24319    
24320                    if (list.size() == 2) {
24321                            return list.get(1);
24322                    }
24323                    else {
24324                            return null;
24325                    }
24326            }
24327    
24328            /**
24329             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24330             *
24331             * @param groupId the group ID
24332             * @param classNameId the class name ID
24333             * @param layoutUuid the layout uuid
24334             * @return the matching journal articles that the user has permission to view
24335             * @throws SystemException if a system exception occurred
24336             */
24337            @Override
24338            public List<JournalArticle> filterFindByG_C_L(long groupId,
24339                    long classNameId, String layoutUuid) throws SystemException {
24340                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
24341                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24342            }
24343    
24344            /**
24345             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24346             *
24347             * <p>
24348             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24349             * </p>
24350             *
24351             * @param groupId the group ID
24352             * @param classNameId the class name ID
24353             * @param layoutUuid the layout uuid
24354             * @param start the lower bound of the range of journal articles
24355             * @param end the upper bound of the range of journal articles (not inclusive)
24356             * @return the range of matching journal articles that the user has permission to view
24357             * @throws SystemException if a system exception occurred
24358             */
24359            @Override
24360            public List<JournalArticle> filterFindByG_C_L(long groupId,
24361                    long classNameId, String layoutUuid, int start, int end)
24362                    throws SystemException {
24363                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
24364                            null);
24365            }
24366    
24367            /**
24368             * 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;.
24369             *
24370             * <p>
24371             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24372             * </p>
24373             *
24374             * @param groupId the group ID
24375             * @param classNameId the class name ID
24376             * @param layoutUuid the layout uuid
24377             * @param start the lower bound of the range of journal articles
24378             * @param end the upper bound of the range of journal articles (not inclusive)
24379             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24380             * @return the ordered range of matching journal articles that the user has permission to view
24381             * @throws SystemException if a system exception occurred
24382             */
24383            @Override
24384            public List<JournalArticle> filterFindByG_C_L(long groupId,
24385                    long classNameId, String layoutUuid, int start, int end,
24386                    OrderByComparator orderByComparator) throws SystemException {
24387                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24388                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
24389                                    orderByComparator);
24390                    }
24391    
24392                    StringBundler query = null;
24393    
24394                    if (orderByComparator != null) {
24395                            query = new StringBundler(5 +
24396                                            (orderByComparator.getOrderByFields().length * 3));
24397                    }
24398                    else {
24399                            query = new StringBundler(5);
24400                    }
24401    
24402                    if (getDB().isSupportsInlineDistinct()) {
24403                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24404                    }
24405                    else {
24406                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24407                    }
24408    
24409                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24410    
24411                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24412    
24413                    boolean bindLayoutUuid = false;
24414    
24415                    if (layoutUuid == null) {
24416                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24417                    }
24418                    else if (layoutUuid.equals(StringPool.BLANK)) {
24419                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24420                    }
24421                    else {
24422                            bindLayoutUuid = true;
24423    
24424                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24425                    }
24426    
24427                    if (!getDB().isSupportsInlineDistinct()) {
24428                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24429                    }
24430    
24431                    if (orderByComparator != null) {
24432                            if (getDB().isSupportsInlineDistinct()) {
24433                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24434                                            orderByComparator, true);
24435                            }
24436                            else {
24437                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24438                                            orderByComparator, true);
24439                            }
24440                    }
24441                    else {
24442                            if (getDB().isSupportsInlineDistinct()) {
24443                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24444                            }
24445                            else {
24446                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24447                            }
24448                    }
24449    
24450                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24451                                    JournalArticle.class.getName(),
24452                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24453    
24454                    Session session = null;
24455    
24456                    try {
24457                            session = openSession();
24458    
24459                            SQLQuery q = session.createSQLQuery(sql);
24460    
24461                            if (getDB().isSupportsInlineDistinct()) {
24462                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24463                            }
24464                            else {
24465                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24466                            }
24467    
24468                            QueryPos qPos = QueryPos.getInstance(q);
24469    
24470                            qPos.add(groupId);
24471    
24472                            qPos.add(classNameId);
24473    
24474                            if (bindLayoutUuid) {
24475                                    qPos.add(layoutUuid);
24476                            }
24477    
24478                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24479                                    end);
24480                    }
24481                    catch (Exception e) {
24482                            throw processException(e);
24483                    }
24484                    finally {
24485                            closeSession(session);
24486                    }
24487            }
24488    
24489            /**
24490             * 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;.
24491             *
24492             * @param id the primary key of the current journal article
24493             * @param groupId the group ID
24494             * @param classNameId the class name ID
24495             * @param layoutUuid the layout uuid
24496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24497             * @return the previous, current, and next journal article
24498             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24499             * @throws SystemException if a system exception occurred
24500             */
24501            @Override
24502            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
24503                    long groupId, long classNameId, String layoutUuid,
24504                    OrderByComparator orderByComparator)
24505                    throws NoSuchArticleException, SystemException {
24506                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24507                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
24508                                    layoutUuid, orderByComparator);
24509                    }
24510    
24511                    JournalArticle journalArticle = findByPrimaryKey(id);
24512    
24513                    Session session = null;
24514    
24515                    try {
24516                            session = openSession();
24517    
24518                            JournalArticle[] array = new JournalArticleImpl[3];
24519    
24520                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
24521                                            groupId, classNameId, layoutUuid, orderByComparator, true);
24522    
24523                            array[1] = journalArticle;
24524    
24525                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
24526                                            groupId, classNameId, layoutUuid, orderByComparator, false);
24527    
24528                            return array;
24529                    }
24530                    catch (Exception e) {
24531                            throw processException(e);
24532                    }
24533                    finally {
24534                            closeSession(session);
24535                    }
24536            }
24537    
24538            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
24539                    JournalArticle journalArticle, long groupId, long classNameId,
24540                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
24541                    StringBundler query = null;
24542    
24543                    if (orderByComparator != null) {
24544                            query = new StringBundler(6 +
24545                                            (orderByComparator.getOrderByFields().length * 6));
24546                    }
24547                    else {
24548                            query = new StringBundler(3);
24549                    }
24550    
24551                    if (getDB().isSupportsInlineDistinct()) {
24552                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24553                    }
24554                    else {
24555                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24556                    }
24557    
24558                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24559    
24560                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24561    
24562                    boolean bindLayoutUuid = false;
24563    
24564                    if (layoutUuid == null) {
24565                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24566                    }
24567                    else if (layoutUuid.equals(StringPool.BLANK)) {
24568                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24569                    }
24570                    else {
24571                            bindLayoutUuid = true;
24572    
24573                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24574                    }
24575    
24576                    if (!getDB().isSupportsInlineDistinct()) {
24577                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24578                    }
24579    
24580                    if (orderByComparator != null) {
24581                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24582    
24583                            if (orderByConditionFields.length > 0) {
24584                                    query.append(WHERE_AND);
24585                            }
24586    
24587                            for (int i = 0; i < orderByConditionFields.length; i++) {
24588                                    if (getDB().isSupportsInlineDistinct()) {
24589                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24590                                    }
24591                                    else {
24592                                            query.append(_ORDER_BY_ENTITY_TABLE);
24593                                    }
24594    
24595                                    query.append(orderByConditionFields[i]);
24596    
24597                                    if ((i + 1) < orderByConditionFields.length) {
24598                                            if (orderByComparator.isAscending() ^ previous) {
24599                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24600                                            }
24601                                            else {
24602                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24603                                            }
24604                                    }
24605                                    else {
24606                                            if (orderByComparator.isAscending() ^ previous) {
24607                                                    query.append(WHERE_GREATER_THAN);
24608                                            }
24609                                            else {
24610                                                    query.append(WHERE_LESSER_THAN);
24611                                            }
24612                                    }
24613                            }
24614    
24615                            query.append(ORDER_BY_CLAUSE);
24616    
24617                            String[] orderByFields = orderByComparator.getOrderByFields();
24618    
24619                            for (int i = 0; i < orderByFields.length; i++) {
24620                                    if (getDB().isSupportsInlineDistinct()) {
24621                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24622                                    }
24623                                    else {
24624                                            query.append(_ORDER_BY_ENTITY_TABLE);
24625                                    }
24626    
24627                                    query.append(orderByFields[i]);
24628    
24629                                    if ((i + 1) < orderByFields.length) {
24630                                            if (orderByComparator.isAscending() ^ previous) {
24631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24632                                            }
24633                                            else {
24634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24635                                            }
24636                                    }
24637                                    else {
24638                                            if (orderByComparator.isAscending() ^ previous) {
24639                                                    query.append(ORDER_BY_ASC);
24640                                            }
24641                                            else {
24642                                                    query.append(ORDER_BY_DESC);
24643                                            }
24644                                    }
24645                            }
24646                    }
24647                    else {
24648                            if (getDB().isSupportsInlineDistinct()) {
24649                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24650                            }
24651                            else {
24652                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24653                            }
24654                    }
24655    
24656                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24657                                    JournalArticle.class.getName(),
24658                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24659    
24660                    SQLQuery q = session.createSQLQuery(sql);
24661    
24662                    q.setFirstResult(0);
24663                    q.setMaxResults(2);
24664    
24665                    if (getDB().isSupportsInlineDistinct()) {
24666                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24667                    }
24668                    else {
24669                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24670                    }
24671    
24672                    QueryPos qPos = QueryPos.getInstance(q);
24673    
24674                    qPos.add(groupId);
24675    
24676                    qPos.add(classNameId);
24677    
24678                    if (bindLayoutUuid) {
24679                            qPos.add(layoutUuid);
24680                    }
24681    
24682                    if (orderByComparator != null) {
24683                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24684    
24685                            for (Object value : values) {
24686                                    qPos.add(value);
24687                            }
24688                    }
24689    
24690                    List<JournalArticle> list = q.list();
24691    
24692                    if (list.size() == 2) {
24693                            return list.get(1);
24694                    }
24695                    else {
24696                            return null;
24697                    }
24698            }
24699    
24700            /**
24701             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
24702             *
24703             * @param groupId the group ID
24704             * @param classNameId the class name ID
24705             * @param layoutUuid the layout uuid
24706             * @throws SystemException if a system exception occurred
24707             */
24708            @Override
24709            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
24710                    throws SystemException {
24711                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
24712                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24713                            remove(journalArticle);
24714                    }
24715            }
24716    
24717            /**
24718             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24719             *
24720             * @param groupId the group ID
24721             * @param classNameId the class name ID
24722             * @param layoutUuid the layout uuid
24723             * @return the number of matching journal articles
24724             * @throws SystemException if a system exception occurred
24725             */
24726            @Override
24727            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
24728                    throws SystemException {
24729                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
24730    
24731                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
24732    
24733                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24734                                    this);
24735    
24736                    if (count == null) {
24737                            StringBundler query = new StringBundler(4);
24738    
24739                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24740    
24741                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24742    
24743                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24744    
24745                            boolean bindLayoutUuid = false;
24746    
24747                            if (layoutUuid == null) {
24748                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24749                            }
24750                            else if (layoutUuid.equals(StringPool.BLANK)) {
24751                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24752                            }
24753                            else {
24754                                    bindLayoutUuid = true;
24755    
24756                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24757                            }
24758    
24759                            String sql = query.toString();
24760    
24761                            Session session = null;
24762    
24763                            try {
24764                                    session = openSession();
24765    
24766                                    Query q = session.createQuery(sql);
24767    
24768                                    QueryPos qPos = QueryPos.getInstance(q);
24769    
24770                                    qPos.add(groupId);
24771    
24772                                    qPos.add(classNameId);
24773    
24774                                    if (bindLayoutUuid) {
24775                                            qPos.add(layoutUuid);
24776                                    }
24777    
24778                                    count = (Long)q.uniqueResult();
24779    
24780                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24781                            }
24782                            catch (Exception e) {
24783                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24784    
24785                                    throw processException(e);
24786                            }
24787                            finally {
24788                                    closeSession(session);
24789                            }
24790                    }
24791    
24792                    return count.intValue();
24793            }
24794    
24795            /**
24796             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24797             *
24798             * @param groupId the group ID
24799             * @param classNameId the class name ID
24800             * @param layoutUuid the layout uuid
24801             * @return the number of matching journal articles that the user has permission to view
24802             * @throws SystemException if a system exception occurred
24803             */
24804            @Override
24805            public int filterCountByG_C_L(long groupId, long classNameId,
24806                    String layoutUuid) throws SystemException {
24807                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24808                            return countByG_C_L(groupId, classNameId, layoutUuid);
24809                    }
24810    
24811                    StringBundler query = new StringBundler(4);
24812    
24813                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
24814    
24815                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24816    
24817                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24818    
24819                    boolean bindLayoutUuid = false;
24820    
24821                    if (layoutUuid == null) {
24822                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24823                    }
24824                    else if (layoutUuid.equals(StringPool.BLANK)) {
24825                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24826                    }
24827                    else {
24828                            bindLayoutUuid = true;
24829    
24830                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24831                    }
24832    
24833                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24834                                    JournalArticle.class.getName(),
24835                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24836    
24837                    Session session = null;
24838    
24839                    try {
24840                            session = openSession();
24841    
24842                            SQLQuery q = session.createSQLQuery(sql);
24843    
24844                            q.addScalar(COUNT_COLUMN_NAME,
24845                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24846    
24847                            QueryPos qPos = QueryPos.getInstance(q);
24848    
24849                            qPos.add(groupId);
24850    
24851                            qPos.add(classNameId);
24852    
24853                            if (bindLayoutUuid) {
24854                                    qPos.add(layoutUuid);
24855                            }
24856    
24857                            Long count = (Long)q.uniqueResult();
24858    
24859                            return count.intValue();
24860                    }
24861                    catch (Exception e) {
24862                            throw processException(e);
24863                    }
24864                    finally {
24865                            closeSession(session);
24866                    }
24867            }
24868    
24869            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
24870            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24871            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24872            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24873            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
24874            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24875                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24876                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
24877                            new String[] {
24878                                    Long.class.getName(), String.class.getName(),
24879                                    Double.class.getName()
24880                            },
24881                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24882                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24883                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24884            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24885                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24886                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
24887                            new String[] {
24888                                    Long.class.getName(), String.class.getName(),
24889                                    Double.class.getName()
24890                            });
24891    
24892            /**
24893             * 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.
24894             *
24895             * @param groupId the group ID
24896             * @param articleId the article ID
24897             * @param version the version
24898             * @return the matching journal article
24899             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24900             * @throws SystemException if a system exception occurred
24901             */
24902            @Override
24903            public JournalArticle findByG_A_V(long groupId, String articleId,
24904                    double version) throws NoSuchArticleException, SystemException {
24905                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
24906    
24907                    if (journalArticle == null) {
24908                            StringBundler msg = new StringBundler(8);
24909    
24910                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24911    
24912                            msg.append("groupId=");
24913                            msg.append(groupId);
24914    
24915                            msg.append(", articleId=");
24916                            msg.append(articleId);
24917    
24918                            msg.append(", version=");
24919                            msg.append(version);
24920    
24921                            msg.append(StringPool.CLOSE_CURLY_BRACE);
24922    
24923                            if (_log.isWarnEnabled()) {
24924                                    _log.warn(msg.toString());
24925                            }
24926    
24927                            throw new NoSuchArticleException(msg.toString());
24928                    }
24929    
24930                    return journalArticle;
24931            }
24932    
24933            /**
24934             * 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.
24935             *
24936             * @param groupId the group ID
24937             * @param articleId the article ID
24938             * @param version the version
24939             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24940             * @throws SystemException if a system exception occurred
24941             */
24942            @Override
24943            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24944                    double version) throws SystemException {
24945                    return fetchByG_A_V(groupId, articleId, version, true);
24946            }
24947    
24948            /**
24949             * 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.
24950             *
24951             * @param groupId the group ID
24952             * @param articleId the article ID
24953             * @param version the version
24954             * @param retrieveFromCache whether to use the finder cache
24955             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24956             * @throws SystemException if a system exception occurred
24957             */
24958            @Override
24959            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24960                    double version, boolean retrieveFromCache) throws SystemException {
24961                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24962    
24963                    Object result = null;
24964    
24965                    if (retrieveFromCache) {
24966                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
24967                                            finderArgs, this);
24968                    }
24969    
24970                    if (result instanceof JournalArticle) {
24971                            JournalArticle journalArticle = (JournalArticle)result;
24972    
24973                            if ((groupId != journalArticle.getGroupId()) ||
24974                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
24975                                            (version != journalArticle.getVersion())) {
24976                                    result = null;
24977                            }
24978                    }
24979    
24980                    if (result == null) {
24981                            StringBundler query = new StringBundler(5);
24982    
24983                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24984    
24985                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24986    
24987                            boolean bindArticleId = false;
24988    
24989                            if (articleId == null) {
24990                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24991                            }
24992                            else if (articleId.equals(StringPool.BLANK)) {
24993                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24994                            }
24995                            else {
24996                                    bindArticleId = true;
24997    
24998                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24999                            }
25000    
25001                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
25002    
25003                            String sql = query.toString();
25004    
25005                            Session session = null;
25006    
25007                            try {
25008                                    session = openSession();
25009    
25010                                    Query q = session.createQuery(sql);
25011    
25012                                    QueryPos qPos = QueryPos.getInstance(q);
25013    
25014                                    qPos.add(groupId);
25015    
25016                                    if (bindArticleId) {
25017                                            qPos.add(articleId);
25018                                    }
25019    
25020                                    qPos.add(version);
25021    
25022                                    List<JournalArticle> list = q.list();
25023    
25024                                    if (list.isEmpty()) {
25025                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
25026                                                    finderArgs, list);
25027                                    }
25028                                    else {
25029                                            JournalArticle journalArticle = list.get(0);
25030    
25031                                            result = journalArticle;
25032    
25033                                            cacheResult(journalArticle);
25034    
25035                                            if ((journalArticle.getGroupId() != groupId) ||
25036                                                            (journalArticle.getArticleId() == null) ||
25037                                                            !journalArticle.getArticleId().equals(articleId) ||
25038                                                            (journalArticle.getVersion() != version)) {
25039                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
25040                                                            finderArgs, journalArticle);
25041                                            }
25042                                    }
25043                            }
25044                            catch (Exception e) {
25045                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
25046                                            finderArgs);
25047    
25048                                    throw processException(e);
25049                            }
25050                            finally {
25051                                    closeSession(session);
25052                            }
25053                    }
25054    
25055                    if (result instanceof List<?>) {
25056                            return null;
25057                    }
25058                    else {
25059                            return (JournalArticle)result;
25060                    }
25061            }
25062    
25063            /**
25064             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
25065             *
25066             * @param groupId the group ID
25067             * @param articleId the article ID
25068             * @param version the version
25069             * @return the journal article that was removed
25070             * @throws SystemException if a system exception occurred
25071             */
25072            @Override
25073            public JournalArticle removeByG_A_V(long groupId, String articleId,
25074                    double version) throws NoSuchArticleException, SystemException {
25075                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
25076    
25077                    return remove(journalArticle);
25078            }
25079    
25080            /**
25081             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
25082             *
25083             * @param groupId the group ID
25084             * @param articleId the article ID
25085             * @param version the version
25086             * @return the number of matching journal articles
25087             * @throws SystemException if a system exception occurred
25088             */
25089            @Override
25090            public int countByG_A_V(long groupId, String articleId, double version)
25091                    throws SystemException {
25092                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
25093    
25094                    Object[] finderArgs = new Object[] { groupId, articleId, version };
25095    
25096                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25097                                    this);
25098    
25099                    if (count == null) {
25100                            StringBundler query = new StringBundler(4);
25101    
25102                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25103    
25104                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
25105    
25106                            boolean bindArticleId = false;
25107    
25108                            if (articleId == null) {
25109                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
25110                            }
25111                            else if (articleId.equals(StringPool.BLANK)) {
25112                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
25113                            }
25114                            else {
25115                                    bindArticleId = true;
25116    
25117                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
25118                            }
25119    
25120                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
25121    
25122                            String sql = query.toString();
25123    
25124                            Session session = null;
25125    
25126                            try {
25127                                    session = openSession();
25128    
25129                                    Query q = session.createQuery(sql);
25130    
25131                                    QueryPos qPos = QueryPos.getInstance(q);
25132    
25133                                    qPos.add(groupId);
25134    
25135                                    if (bindArticleId) {
25136                                            qPos.add(articleId);
25137                                    }
25138    
25139                                    qPos.add(version);
25140    
25141                                    count = (Long)q.uniqueResult();
25142    
25143                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25144                            }
25145                            catch (Exception e) {
25146                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25147    
25148                                    throw processException(e);
25149                            }
25150                            finally {
25151                                    closeSession(session);
25152                            }
25153                    }
25154    
25155                    return count.intValue();
25156            }
25157    
25158            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
25159            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
25160            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
25161            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
25162            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
25163            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25164                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25165                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
25166                            "findByG_A_ST",
25167                            new String[] {
25168                                    Long.class.getName(), String.class.getName(),
25169                                    Integer.class.getName(),
25170                                    
25171                            Integer.class.getName(), Integer.class.getName(),
25172                                    OrderByComparator.class.getName()
25173                            });
25174            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
25175                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25176                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25177                            JournalArticleImpl.class,
25178                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
25179                            new String[] {
25180                                    Long.class.getName(), String.class.getName(),
25181                                    Integer.class.getName()
25182                            },
25183                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
25184                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
25185                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
25186                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
25187            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25188                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
25189                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
25190                            new String[] {
25191                                    Long.class.getName(), String.class.getName(),
25192                                    Integer.class.getName()
25193                            });
25194            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25195                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
25196                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
25197                            new String[] {
25198                                    Long.class.getName(), String.class.getName(),
25199                                    Integer.class.getName()
25200                            });
25201    
25202            /**
25203             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25204             *
25205             * @param groupId the group ID
25206             * @param articleId the article ID
25207             * @param status the status
25208             * @return the matching journal articles
25209             * @throws SystemException if a system exception occurred
25210             */
25211            @Override
25212            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25213                    int status) throws SystemException {
25214                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
25215                            QueryUtil.ALL_POS, null);
25216            }
25217    
25218            /**
25219             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25220             *
25221             * <p>
25222             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25223             * </p>
25224             *
25225             * @param groupId the group ID
25226             * @param articleId the article ID
25227             * @param status the status
25228             * @param start the lower bound of the range of journal articles
25229             * @param end the upper bound of the range of journal articles (not inclusive)
25230             * @return the range of matching journal articles
25231             * @throws SystemException if a system exception occurred
25232             */
25233            @Override
25234            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25235                    int status, int start, int end) throws SystemException {
25236                    return findByG_A_ST(groupId, articleId, status, start, end, null);
25237            }
25238    
25239            /**
25240             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25241             *
25242             * <p>
25243             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25244             * </p>
25245             *
25246             * @param groupId the group ID
25247             * @param articleId the article ID
25248             * @param status the status
25249             * @param start the lower bound of the range of journal articles
25250             * @param end the upper bound of the range of journal articles (not inclusive)
25251             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25252             * @return the ordered range of matching journal articles
25253             * @throws SystemException if a system exception occurred
25254             */
25255            @Override
25256            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25257                    int status, int start, int end, OrderByComparator orderByComparator)
25258                    throws SystemException {
25259                    boolean pagination = true;
25260                    FinderPath finderPath = null;
25261                    Object[] finderArgs = null;
25262    
25263                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25264                                    (orderByComparator == null)) {
25265                            pagination = false;
25266                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
25267                            finderArgs = new Object[] { groupId, articleId, status };
25268                    }
25269                    else {
25270                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
25271                            finderArgs = new Object[] {
25272                                            groupId, articleId, status,
25273                                            
25274                                            start, end, orderByComparator
25275                                    };
25276                    }
25277    
25278                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
25279                                    finderArgs, this);
25280    
25281                    if ((list != null) && !list.isEmpty()) {
25282                            for (JournalArticle journalArticle : list) {
25283                                    if ((groupId != journalArticle.getGroupId()) ||
25284                                                    !Validator.equals(articleId,
25285                                                            journalArticle.getArticleId()) ||
25286                                                    (status != journalArticle.getStatus())) {
25287                                            list = null;
25288    
25289                                            break;
25290                                    }
25291                            }
25292                    }
25293    
25294                    if (list == null) {
25295                            StringBundler query = null;
25296    
25297                            if (orderByComparator != null) {
25298                                    query = new StringBundler(5 +
25299                                                    (orderByComparator.getOrderByFields().length * 3));
25300                            }
25301                            else {
25302                                    query = new StringBundler(5);
25303                            }
25304    
25305                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25306    
25307                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25308    
25309                            boolean bindArticleId = false;
25310    
25311                            if (articleId == null) {
25312                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25313                            }
25314                            else if (articleId.equals(StringPool.BLANK)) {
25315                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25316                            }
25317                            else {
25318                                    bindArticleId = true;
25319    
25320                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25321                            }
25322    
25323                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25324    
25325                            if (orderByComparator != null) {
25326                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25327                                            orderByComparator);
25328                            }
25329                            else
25330                             if (pagination) {
25331                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25332                            }
25333    
25334                            String sql = query.toString();
25335    
25336                            Session session = null;
25337    
25338                            try {
25339                                    session = openSession();
25340    
25341                                    Query q = session.createQuery(sql);
25342    
25343                                    QueryPos qPos = QueryPos.getInstance(q);
25344    
25345                                    qPos.add(groupId);
25346    
25347                                    if (bindArticleId) {
25348                                            qPos.add(articleId);
25349                                    }
25350    
25351                                    qPos.add(status);
25352    
25353                                    if (!pagination) {
25354                                            list = (List<JournalArticle>)QueryUtil.list(q,
25355                                                            getDialect(), start, end, false);
25356    
25357                                            Collections.sort(list);
25358    
25359                                            list = new UnmodifiableList<JournalArticle>(list);
25360                                    }
25361                                    else {
25362                                            list = (List<JournalArticle>)QueryUtil.list(q,
25363                                                            getDialect(), start, end);
25364                                    }
25365    
25366                                    cacheResult(list);
25367    
25368                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
25369                            }
25370                            catch (Exception e) {
25371                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25372    
25373                                    throw processException(e);
25374                            }
25375                            finally {
25376                                    closeSession(session);
25377                            }
25378                    }
25379    
25380                    return list;
25381            }
25382    
25383            /**
25384             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25385             *
25386             * @param groupId the group ID
25387             * @param articleId the article ID
25388             * @param status the status
25389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25390             * @return the first matching journal article
25391             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25392             * @throws SystemException if a system exception occurred
25393             */
25394            @Override
25395            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
25396                    int status, OrderByComparator orderByComparator)
25397                    throws NoSuchArticleException, SystemException {
25398                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
25399                                    status, orderByComparator);
25400    
25401                    if (journalArticle != null) {
25402                            return journalArticle;
25403                    }
25404    
25405                    StringBundler msg = new StringBundler(8);
25406    
25407                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25408    
25409                    msg.append("groupId=");
25410                    msg.append(groupId);
25411    
25412                    msg.append(", articleId=");
25413                    msg.append(articleId);
25414    
25415                    msg.append(", status=");
25416                    msg.append(status);
25417    
25418                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25419    
25420                    throw new NoSuchArticleException(msg.toString());
25421            }
25422    
25423            /**
25424             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25425             *
25426             * @param groupId the group ID
25427             * @param articleId the article ID
25428             * @param status the status
25429             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25430             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
25431             * @throws SystemException if a system exception occurred
25432             */
25433            @Override
25434            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
25435                    int status, OrderByComparator orderByComparator)
25436                    throws SystemException {
25437                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
25438                                    1, orderByComparator);
25439    
25440                    if (!list.isEmpty()) {
25441                            return list.get(0);
25442                    }
25443    
25444                    return null;
25445            }
25446    
25447            /**
25448             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25449             *
25450             * @param groupId the group ID
25451             * @param articleId the article ID
25452             * @param status the status
25453             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25454             * @return the last matching journal article
25455             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25456             * @throws SystemException if a system exception occurred
25457             */
25458            @Override
25459            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
25460                    int status, OrderByComparator orderByComparator)
25461                    throws NoSuchArticleException, SystemException {
25462                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
25463                                    status, orderByComparator);
25464    
25465                    if (journalArticle != null) {
25466                            return journalArticle;
25467                    }
25468    
25469                    StringBundler msg = new StringBundler(8);
25470    
25471                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25472    
25473                    msg.append("groupId=");
25474                    msg.append(groupId);
25475    
25476                    msg.append(", articleId=");
25477                    msg.append(articleId);
25478    
25479                    msg.append(", status=");
25480                    msg.append(status);
25481    
25482                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25483    
25484                    throw new NoSuchArticleException(msg.toString());
25485            }
25486    
25487            /**
25488             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25489             *
25490             * @param groupId the group ID
25491             * @param articleId the article ID
25492             * @param status the status
25493             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25494             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
25495             * @throws SystemException if a system exception occurred
25496             */
25497            @Override
25498            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
25499                    int status, OrderByComparator orderByComparator)
25500                    throws SystemException {
25501                    int count = countByG_A_ST(groupId, articleId, status);
25502    
25503                    if (count == 0) {
25504                            return null;
25505                    }
25506    
25507                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
25508                                    count - 1, count, orderByComparator);
25509    
25510                    if (!list.isEmpty()) {
25511                            return list.get(0);
25512                    }
25513    
25514                    return null;
25515            }
25516    
25517            /**
25518             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25519             *
25520             * @param id the primary key of the current journal article
25521             * @param groupId the group ID
25522             * @param articleId the article ID
25523             * @param status the status
25524             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25525             * @return the previous, current, and next journal article
25526             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25527             * @throws SystemException if a system exception occurred
25528             */
25529            @Override
25530            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
25531                    String articleId, int status, OrderByComparator orderByComparator)
25532                    throws NoSuchArticleException, SystemException {
25533                    JournalArticle journalArticle = findByPrimaryKey(id);
25534    
25535                    Session session = null;
25536    
25537                    try {
25538                            session = openSession();
25539    
25540                            JournalArticle[] array = new JournalArticleImpl[3];
25541    
25542                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
25543                                            groupId, articleId, status, orderByComparator, true);
25544    
25545                            array[1] = journalArticle;
25546    
25547                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
25548                                            groupId, articleId, status, orderByComparator, false);
25549    
25550                            return array;
25551                    }
25552                    catch (Exception e) {
25553                            throw processException(e);
25554                    }
25555                    finally {
25556                            closeSession(session);
25557                    }
25558            }
25559    
25560            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
25561                    JournalArticle journalArticle, long groupId, String articleId,
25562                    int status, OrderByComparator orderByComparator, boolean previous) {
25563                    StringBundler query = null;
25564    
25565                    if (orderByComparator != null) {
25566                            query = new StringBundler(6 +
25567                                            (orderByComparator.getOrderByFields().length * 6));
25568                    }
25569                    else {
25570                            query = new StringBundler(3);
25571                    }
25572    
25573                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25574    
25575                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25576    
25577                    boolean bindArticleId = false;
25578    
25579                    if (articleId == null) {
25580                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25581                    }
25582                    else if (articleId.equals(StringPool.BLANK)) {
25583                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25584                    }
25585                    else {
25586                            bindArticleId = true;
25587    
25588                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25589                    }
25590    
25591                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25592    
25593                    if (orderByComparator != null) {
25594                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25595    
25596                            if (orderByConditionFields.length > 0) {
25597                                    query.append(WHERE_AND);
25598                            }
25599    
25600                            for (int i = 0; i < orderByConditionFields.length; i++) {
25601                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25602                                    query.append(orderByConditionFields[i]);
25603    
25604                                    if ((i + 1) < orderByConditionFields.length) {
25605                                            if (orderByComparator.isAscending() ^ previous) {
25606                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25607                                            }
25608                                            else {
25609                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25610                                            }
25611                                    }
25612                                    else {
25613                                            if (orderByComparator.isAscending() ^ previous) {
25614                                                    query.append(WHERE_GREATER_THAN);
25615                                            }
25616                                            else {
25617                                                    query.append(WHERE_LESSER_THAN);
25618                                            }
25619                                    }
25620                            }
25621    
25622                            query.append(ORDER_BY_CLAUSE);
25623    
25624                            String[] orderByFields = orderByComparator.getOrderByFields();
25625    
25626                            for (int i = 0; i < orderByFields.length; i++) {
25627                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25628                                    query.append(orderByFields[i]);
25629    
25630                                    if ((i + 1) < orderByFields.length) {
25631                                            if (orderByComparator.isAscending() ^ previous) {
25632                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25633                                            }
25634                                            else {
25635                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25636                                            }
25637                                    }
25638                                    else {
25639                                            if (orderByComparator.isAscending() ^ previous) {
25640                                                    query.append(ORDER_BY_ASC);
25641                                            }
25642                                            else {
25643                                                    query.append(ORDER_BY_DESC);
25644                                            }
25645                                    }
25646                            }
25647                    }
25648                    else {
25649                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25650                    }
25651    
25652                    String sql = query.toString();
25653    
25654                    Query q = session.createQuery(sql);
25655    
25656                    q.setFirstResult(0);
25657                    q.setMaxResults(2);
25658    
25659                    QueryPos qPos = QueryPos.getInstance(q);
25660    
25661                    qPos.add(groupId);
25662    
25663                    if (bindArticleId) {
25664                            qPos.add(articleId);
25665                    }
25666    
25667                    qPos.add(status);
25668    
25669                    if (orderByComparator != null) {
25670                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25671    
25672                            for (Object value : values) {
25673                                    qPos.add(value);
25674                            }
25675                    }
25676    
25677                    List<JournalArticle> list = q.list();
25678    
25679                    if (list.size() == 2) {
25680                            return list.get(1);
25681                    }
25682                    else {
25683                            return null;
25684                    }
25685            }
25686    
25687            /**
25688             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25689             *
25690             * @param groupId the group ID
25691             * @param articleId the article ID
25692             * @param status the status
25693             * @return the matching journal articles that the user has permission to view
25694             * @throws SystemException if a system exception occurred
25695             */
25696            @Override
25697            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25698                    String articleId, int status) throws SystemException {
25699                    return filterFindByG_A_ST(groupId, articleId, status,
25700                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25701            }
25702    
25703            /**
25704             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25705             *
25706             * <p>
25707             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25708             * </p>
25709             *
25710             * @param groupId the group ID
25711             * @param articleId the article ID
25712             * @param status the status
25713             * @param start the lower bound of the range of journal articles
25714             * @param end the upper bound of the range of journal articles (not inclusive)
25715             * @return the range of matching journal articles that the user has permission to view
25716             * @throws SystemException if a system exception occurred
25717             */
25718            @Override
25719            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25720                    String articleId, int status, int start, int end)
25721                    throws SystemException {
25722                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
25723            }
25724    
25725            /**
25726             * 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;.
25727             *
25728             * <p>
25729             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25730             * </p>
25731             *
25732             * @param groupId the group ID
25733             * @param articleId the article ID
25734             * @param status the status
25735             * @param start the lower bound of the range of journal articles
25736             * @param end the upper bound of the range of journal articles (not inclusive)
25737             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25738             * @return the ordered range of matching journal articles that the user has permission to view
25739             * @throws SystemException if a system exception occurred
25740             */
25741            @Override
25742            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25743                    String articleId, int status, int start, int end,
25744                    OrderByComparator orderByComparator) throws SystemException {
25745                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25746                            return findByG_A_ST(groupId, articleId, status, start, end,
25747                                    orderByComparator);
25748                    }
25749    
25750                    StringBundler query = null;
25751    
25752                    if (orderByComparator != null) {
25753                            query = new StringBundler(5 +
25754                                            (orderByComparator.getOrderByFields().length * 3));
25755                    }
25756                    else {
25757                            query = new StringBundler(5);
25758                    }
25759    
25760                    if (getDB().isSupportsInlineDistinct()) {
25761                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25762                    }
25763                    else {
25764                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25765                    }
25766    
25767                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25768    
25769                    boolean bindArticleId = false;
25770    
25771                    if (articleId == null) {
25772                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25773                    }
25774                    else if (articleId.equals(StringPool.BLANK)) {
25775                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25776                    }
25777                    else {
25778                            bindArticleId = true;
25779    
25780                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25781                    }
25782    
25783                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25784    
25785                    if (!getDB().isSupportsInlineDistinct()) {
25786                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25787                    }
25788    
25789                    if (orderByComparator != null) {
25790                            if (getDB().isSupportsInlineDistinct()) {
25791                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25792                                            orderByComparator, true);
25793                            }
25794                            else {
25795                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25796                                            orderByComparator, true);
25797                            }
25798                    }
25799                    else {
25800                            if (getDB().isSupportsInlineDistinct()) {
25801                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25802                            }
25803                            else {
25804                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25805                            }
25806                    }
25807    
25808                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25809                                    JournalArticle.class.getName(),
25810                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25811    
25812                    Session session = null;
25813    
25814                    try {
25815                            session = openSession();
25816    
25817                            SQLQuery q = session.createSQLQuery(sql);
25818    
25819                            if (getDB().isSupportsInlineDistinct()) {
25820                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25821                            }
25822                            else {
25823                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25824                            }
25825    
25826                            QueryPos qPos = QueryPos.getInstance(q);
25827    
25828                            qPos.add(groupId);
25829    
25830                            if (bindArticleId) {
25831                                    qPos.add(articleId);
25832                            }
25833    
25834                            qPos.add(status);
25835    
25836                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25837                                    end);
25838                    }
25839                    catch (Exception e) {
25840                            throw processException(e);
25841                    }
25842                    finally {
25843                            closeSession(session);
25844                    }
25845            }
25846    
25847            /**
25848             * 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;.
25849             *
25850             * @param id the primary key of the current journal article
25851             * @param groupId the group ID
25852             * @param articleId the article ID
25853             * @param status the status
25854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25855             * @return the previous, current, and next journal article
25856             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25857             * @throws SystemException if a system exception occurred
25858             */
25859            @Override
25860            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
25861                    long groupId, String articleId, int status,
25862                    OrderByComparator orderByComparator)
25863                    throws NoSuchArticleException, SystemException {
25864                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25865                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
25866                                    orderByComparator);
25867                    }
25868    
25869                    JournalArticle journalArticle = findByPrimaryKey(id);
25870    
25871                    Session session = null;
25872    
25873                    try {
25874                            session = openSession();
25875    
25876                            JournalArticle[] array = new JournalArticleImpl[3];
25877    
25878                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25879                                            groupId, articleId, status, orderByComparator, true);
25880    
25881                            array[1] = journalArticle;
25882    
25883                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25884                                            groupId, articleId, status, orderByComparator, false);
25885    
25886                            return array;
25887                    }
25888                    catch (Exception e) {
25889                            throw processException(e);
25890                    }
25891                    finally {
25892                            closeSession(session);
25893                    }
25894            }
25895    
25896            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
25897                    JournalArticle journalArticle, long groupId, String articleId,
25898                    int status, OrderByComparator orderByComparator, boolean previous) {
25899                    StringBundler query = null;
25900    
25901                    if (orderByComparator != null) {
25902                            query = new StringBundler(6 +
25903                                            (orderByComparator.getOrderByFields().length * 6));
25904                    }
25905                    else {
25906                            query = new StringBundler(3);
25907                    }
25908    
25909                    if (getDB().isSupportsInlineDistinct()) {
25910                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25911                    }
25912                    else {
25913                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25914                    }
25915    
25916                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25917    
25918                    boolean bindArticleId = false;
25919    
25920                    if (articleId == null) {
25921                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25922                    }
25923                    else if (articleId.equals(StringPool.BLANK)) {
25924                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25925                    }
25926                    else {
25927                            bindArticleId = true;
25928    
25929                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25930                    }
25931    
25932                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25933    
25934                    if (!getDB().isSupportsInlineDistinct()) {
25935                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25936                    }
25937    
25938                    if (orderByComparator != null) {
25939                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25940    
25941                            if (orderByConditionFields.length > 0) {
25942                                    query.append(WHERE_AND);
25943                            }
25944    
25945                            for (int i = 0; i < orderByConditionFields.length; i++) {
25946                                    if (getDB().isSupportsInlineDistinct()) {
25947                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25948                                    }
25949                                    else {
25950                                            query.append(_ORDER_BY_ENTITY_TABLE);
25951                                    }
25952    
25953                                    query.append(orderByConditionFields[i]);
25954    
25955                                    if ((i + 1) < orderByConditionFields.length) {
25956                                            if (orderByComparator.isAscending() ^ previous) {
25957                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25958                                            }
25959                                            else {
25960                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25961                                            }
25962                                    }
25963                                    else {
25964                                            if (orderByComparator.isAscending() ^ previous) {
25965                                                    query.append(WHERE_GREATER_THAN);
25966                                            }
25967                                            else {
25968                                                    query.append(WHERE_LESSER_THAN);
25969                                            }
25970                                    }
25971                            }
25972    
25973                            query.append(ORDER_BY_CLAUSE);
25974    
25975                            String[] orderByFields = orderByComparator.getOrderByFields();
25976    
25977                            for (int i = 0; i < orderByFields.length; i++) {
25978                                    if (getDB().isSupportsInlineDistinct()) {
25979                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25980                                    }
25981                                    else {
25982                                            query.append(_ORDER_BY_ENTITY_TABLE);
25983                                    }
25984    
25985                                    query.append(orderByFields[i]);
25986    
25987                                    if ((i + 1) < orderByFields.length) {
25988                                            if (orderByComparator.isAscending() ^ previous) {
25989                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25990                                            }
25991                                            else {
25992                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25993                                            }
25994                                    }
25995                                    else {
25996                                            if (orderByComparator.isAscending() ^ previous) {
25997                                                    query.append(ORDER_BY_ASC);
25998                                            }
25999                                            else {
26000                                                    query.append(ORDER_BY_DESC);
26001                                            }
26002                                    }
26003                            }
26004                    }
26005                    else {
26006                            if (getDB().isSupportsInlineDistinct()) {
26007                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26008                            }
26009                            else {
26010                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26011                            }
26012                    }
26013    
26014                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26015                                    JournalArticle.class.getName(),
26016                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26017    
26018                    SQLQuery q = session.createSQLQuery(sql);
26019    
26020                    q.setFirstResult(0);
26021                    q.setMaxResults(2);
26022    
26023                    if (getDB().isSupportsInlineDistinct()) {
26024                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26025                    }
26026                    else {
26027                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26028                    }
26029    
26030                    QueryPos qPos = QueryPos.getInstance(q);
26031    
26032                    qPos.add(groupId);
26033    
26034                    if (bindArticleId) {
26035                            qPos.add(articleId);
26036                    }
26037    
26038                    qPos.add(status);
26039    
26040                    if (orderByComparator != null) {
26041                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26042    
26043                            for (Object value : values) {
26044                                    qPos.add(value);
26045                            }
26046                    }
26047    
26048                    List<JournalArticle> list = q.list();
26049    
26050                    if (list.size() == 2) {
26051                            return list.get(1);
26052                    }
26053                    else {
26054                            return null;
26055                    }
26056            }
26057    
26058            /**
26059             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
26060             *
26061             * @param groupId the group ID
26062             * @param articleId the article ID
26063             * @param statuses the statuses
26064             * @return the matching journal articles that the user has permission to view
26065             * @throws SystemException if a system exception occurred
26066             */
26067            @Override
26068            public List<JournalArticle> filterFindByG_A_ST(long groupId,
26069                    String articleId, int[] statuses) throws SystemException {
26070                    return filterFindByG_A_ST(groupId, articleId, statuses,
26071                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
26072            }
26073    
26074            /**
26075             * 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;.
26076             *
26077             * <p>
26078             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26079             * </p>
26080             *
26081             * @param groupId the group ID
26082             * @param articleId the article ID
26083             * @param statuses the statuses
26084             * @param start the lower bound of the range of journal articles
26085             * @param end the upper bound of the range of journal articles (not inclusive)
26086             * @return the range of matching journal articles that the user has permission to view
26087             * @throws SystemException if a system exception occurred
26088             */
26089            @Override
26090            public List<JournalArticle> filterFindByG_A_ST(long groupId,
26091                    String articleId, int[] statuses, int start, int end)
26092                    throws SystemException {
26093                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
26094            }
26095    
26096            /**
26097             * 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;.
26098             *
26099             * <p>
26100             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26101             * </p>
26102             *
26103             * @param groupId the group ID
26104             * @param articleId the article ID
26105             * @param statuses the statuses
26106             * @param start the lower bound of the range of journal articles
26107             * @param end the upper bound of the range of journal articles (not inclusive)
26108             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26109             * @return the ordered range of matching journal articles that the user has permission to view
26110             * @throws SystemException if a system exception occurred
26111             */
26112            @Override
26113            public List<JournalArticle> filterFindByG_A_ST(long groupId,
26114                    String articleId, int[] statuses, int start, int end,
26115                    OrderByComparator orderByComparator) throws SystemException {
26116                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26117                            return findByG_A_ST(groupId, articleId, statuses, start, end,
26118                                    orderByComparator);
26119                    }
26120    
26121                    StringBundler query = new StringBundler();
26122    
26123                    if (getDB().isSupportsInlineDistinct()) {
26124                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26125                    }
26126                    else {
26127                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26128                    }
26129    
26130                    boolean conjunctionable = false;
26131    
26132                    if (conjunctionable) {
26133                            query.append(WHERE_AND);
26134                    }
26135    
26136                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26137    
26138                    conjunctionable = true;
26139    
26140                    if (conjunctionable) {
26141                            query.append(WHERE_AND);
26142                    }
26143    
26144                    boolean bindArticleId = false;
26145    
26146                    if (articleId == null) {
26147                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26148                    }
26149                    else if (articleId.equals(StringPool.BLANK)) {
26150                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26151                    }
26152                    else {
26153                            bindArticleId = true;
26154    
26155                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26156                    }
26157    
26158                    conjunctionable = true;
26159    
26160                    if ((statuses == null) || (statuses.length > 0)) {
26161                            if (conjunctionable) {
26162                                    query.append(WHERE_AND);
26163                            }
26164    
26165                            query.append(StringPool.OPEN_PARENTHESIS);
26166    
26167                            for (int i = 0; i < statuses.length; i++) {
26168                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26169    
26170                                    if ((i + 1) < statuses.length) {
26171                                            query.append(WHERE_OR);
26172                                    }
26173                            }
26174    
26175                            query.append(StringPool.CLOSE_PARENTHESIS);
26176    
26177                            conjunctionable = true;
26178                    }
26179    
26180                    if (!getDB().isSupportsInlineDistinct()) {
26181                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26182                    }
26183    
26184                    if (orderByComparator != null) {
26185                            if (getDB().isSupportsInlineDistinct()) {
26186                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26187                                            orderByComparator, true);
26188                            }
26189                            else {
26190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
26191                                            orderByComparator, true);
26192                            }
26193                    }
26194                    else {
26195                            if (getDB().isSupportsInlineDistinct()) {
26196                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26197                            }
26198                            else {
26199                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26200                            }
26201                    }
26202    
26203                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26204                                    JournalArticle.class.getName(),
26205                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26206    
26207                    Session session = null;
26208    
26209                    try {
26210                            session = openSession();
26211    
26212                            SQLQuery q = session.createSQLQuery(sql);
26213    
26214                            if (getDB().isSupportsInlineDistinct()) {
26215                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26216                            }
26217                            else {
26218                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26219                            }
26220    
26221                            QueryPos qPos = QueryPos.getInstance(q);
26222    
26223                            qPos.add(groupId);
26224    
26225                            if (bindArticleId) {
26226                                    qPos.add(articleId);
26227                            }
26228    
26229                            if (statuses != null) {
26230                                    qPos.add(statuses);
26231                            }
26232    
26233                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
26234                                    end);
26235                    }
26236                    catch (Exception e) {
26237                            throw processException(e);
26238                    }
26239                    finally {
26240                            closeSession(session);
26241                    }
26242            }
26243    
26244            /**
26245             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26246             *
26247             * <p>
26248             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26249             * </p>
26250             *
26251             * @param groupId the group ID
26252             * @param articleId the article ID
26253             * @param statuses the statuses
26254             * @return the matching journal articles
26255             * @throws SystemException if a system exception occurred
26256             */
26257            @Override
26258            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26259                    int[] statuses) throws SystemException {
26260                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
26261                            QueryUtil.ALL_POS, null);
26262            }
26263    
26264            /**
26265             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26266             *
26267             * <p>
26268             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26269             * </p>
26270             *
26271             * @param groupId the group ID
26272             * @param articleId the article ID
26273             * @param statuses the statuses
26274             * @param start the lower bound of the range of journal articles
26275             * @param end the upper bound of the range of journal articles (not inclusive)
26276             * @return the range of matching journal articles
26277             * @throws SystemException if a system exception occurred
26278             */
26279            @Override
26280            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26281                    int[] statuses, int start, int end) throws SystemException {
26282                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
26283            }
26284    
26285            /**
26286             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26287             *
26288             * <p>
26289             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26290             * </p>
26291             *
26292             * @param groupId the group ID
26293             * @param articleId the article ID
26294             * @param statuses the statuses
26295             * @param start the lower bound of the range of journal articles
26296             * @param end the upper bound of the range of journal articles (not inclusive)
26297             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26298             * @return the ordered range of matching journal articles
26299             * @throws SystemException if a system exception occurred
26300             */
26301            @Override
26302            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26303                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
26304                    throws SystemException {
26305                    if ((statuses != null) && (statuses.length == 1)) {
26306                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
26307                                    orderByComparator);
26308                    }
26309    
26310                    boolean pagination = true;
26311                    Object[] finderArgs = null;
26312    
26313                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
26314                                    (orderByComparator == null)) {
26315                            pagination = false;
26316                            finderArgs = new Object[] {
26317                                            groupId, articleId, StringUtil.merge(statuses)
26318                                    };
26319                    }
26320                    else {
26321                            finderArgs = new Object[] {
26322                                            groupId, articleId, StringUtil.merge(statuses),
26323                                            
26324                                            start, end, orderByComparator
26325                                    };
26326                    }
26327    
26328                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
26329                                    finderArgs, this);
26330    
26331                    if ((list != null) && !list.isEmpty()) {
26332                            for (JournalArticle journalArticle : list) {
26333                                    if ((groupId != journalArticle.getGroupId()) ||
26334                                                    !Validator.equals(articleId,
26335                                                            journalArticle.getArticleId()) ||
26336                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
26337                                            list = null;
26338    
26339                                            break;
26340                                    }
26341                            }
26342                    }
26343    
26344                    if (list == null) {
26345                            StringBundler query = new StringBundler();
26346    
26347                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26348    
26349                            boolean conjunctionable = false;
26350    
26351                            if (conjunctionable) {
26352                                    query.append(WHERE_AND);
26353                            }
26354    
26355                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26356    
26357                            conjunctionable = true;
26358    
26359                            if (conjunctionable) {
26360                                    query.append(WHERE_AND);
26361                            }
26362    
26363                            boolean bindArticleId = false;
26364    
26365                            if (articleId == null) {
26366                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26367                            }
26368                            else if (articleId.equals(StringPool.BLANK)) {
26369                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26370                            }
26371                            else {
26372                                    bindArticleId = true;
26373    
26374                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26375                            }
26376    
26377                            conjunctionable = true;
26378    
26379                            if ((statuses == null) || (statuses.length > 0)) {
26380                                    if (conjunctionable) {
26381                                            query.append(WHERE_AND);
26382                                    }
26383    
26384                                    query.append(StringPool.OPEN_PARENTHESIS);
26385    
26386                                    for (int i = 0; i < statuses.length; i++) {
26387                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26388    
26389                                            if ((i + 1) < statuses.length) {
26390                                                    query.append(WHERE_OR);
26391                                            }
26392                                    }
26393    
26394                                    query.append(StringPool.CLOSE_PARENTHESIS);
26395    
26396                                    conjunctionable = true;
26397                            }
26398    
26399                            if (orderByComparator != null) {
26400                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26401                                            orderByComparator);
26402                            }
26403                            else
26404                             if (pagination) {
26405                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26406                            }
26407    
26408                            String sql = query.toString();
26409    
26410                            Session session = null;
26411    
26412                            try {
26413                                    session = openSession();
26414    
26415                                    Query q = session.createQuery(sql);
26416    
26417                                    QueryPos qPos = QueryPos.getInstance(q);
26418    
26419                                    qPos.add(groupId);
26420    
26421                                    if (bindArticleId) {
26422                                            qPos.add(articleId);
26423                                    }
26424    
26425                                    if (statuses != null) {
26426                                            qPos.add(statuses);
26427                                    }
26428    
26429                                    if (!pagination) {
26430                                            list = (List<JournalArticle>)QueryUtil.list(q,
26431                                                            getDialect(), start, end, false);
26432    
26433                                            Collections.sort(list);
26434    
26435                                            list = new UnmodifiableList<JournalArticle>(list);
26436                                    }
26437                                    else {
26438                                            list = (List<JournalArticle>)QueryUtil.list(q,
26439                                                            getDialect(), start, end);
26440                                    }
26441    
26442                                    cacheResult(list);
26443    
26444                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
26445                                            finderArgs, list);
26446                            }
26447                            catch (Exception e) {
26448                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
26449                                            finderArgs);
26450    
26451                                    throw processException(e);
26452                            }
26453                            finally {
26454                                    closeSession(session);
26455                            }
26456                    }
26457    
26458                    return list;
26459            }
26460    
26461            /**
26462             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
26463             *
26464             * @param groupId the group ID
26465             * @param articleId the article ID
26466             * @param status the status
26467             * @throws SystemException if a system exception occurred
26468             */
26469            @Override
26470            public void removeByG_A_ST(long groupId, String articleId, int status)
26471                    throws SystemException {
26472                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
26473                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26474                            remove(journalArticle);
26475                    }
26476            }
26477    
26478            /**
26479             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
26480             *
26481             * @param groupId the group ID
26482             * @param articleId the article ID
26483             * @param status the status
26484             * @return the number of matching journal articles
26485             * @throws SystemException if a system exception occurred
26486             */
26487            @Override
26488            public int countByG_A_ST(long groupId, String articleId, int status)
26489                    throws SystemException {
26490                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
26491    
26492                    Object[] finderArgs = new Object[] { groupId, articleId, status };
26493    
26494                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26495                                    this);
26496    
26497                    if (count == null) {
26498                            StringBundler query = new StringBundler(4);
26499    
26500                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26501    
26502                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
26503    
26504                            boolean bindArticleId = false;
26505    
26506                            if (articleId == null) {
26507                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
26508                            }
26509                            else if (articleId.equals(StringPool.BLANK)) {
26510                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
26511                            }
26512                            else {
26513                                    bindArticleId = true;
26514    
26515                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
26516                            }
26517    
26518                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
26519    
26520                            String sql = query.toString();
26521    
26522                            Session session = null;
26523    
26524                            try {
26525                                    session = openSession();
26526    
26527                                    Query q = session.createQuery(sql);
26528    
26529                                    QueryPos qPos = QueryPos.getInstance(q);
26530    
26531                                    qPos.add(groupId);
26532    
26533                                    if (bindArticleId) {
26534                                            qPos.add(articleId);
26535                                    }
26536    
26537                                    qPos.add(status);
26538    
26539                                    count = (Long)q.uniqueResult();
26540    
26541                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26542                            }
26543                            catch (Exception e) {
26544                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26545    
26546                                    throw processException(e);
26547                            }
26548                            finally {
26549                                    closeSession(session);
26550                            }
26551                    }
26552    
26553                    return count.intValue();
26554            }
26555    
26556            /**
26557             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26558             *
26559             * @param groupId the group ID
26560             * @param articleId the article ID
26561             * @param statuses the statuses
26562             * @return the number of matching journal articles
26563             * @throws SystemException if a system exception occurred
26564             */
26565            @Override
26566            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
26567                    throws SystemException {
26568                    Object[] finderArgs = new Object[] {
26569                                    groupId, articleId, StringUtil.merge(statuses)
26570                            };
26571    
26572                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
26573                                    finderArgs, this);
26574    
26575                    if (count == null) {
26576                            StringBundler query = new StringBundler();
26577    
26578                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26579    
26580                            boolean conjunctionable = false;
26581    
26582                            if (conjunctionable) {
26583                                    query.append(WHERE_AND);
26584                            }
26585    
26586                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26587    
26588                            conjunctionable = true;
26589    
26590                            if (conjunctionable) {
26591                                    query.append(WHERE_AND);
26592                            }
26593    
26594                            boolean bindArticleId = false;
26595    
26596                            if (articleId == null) {
26597                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26598                            }
26599                            else if (articleId.equals(StringPool.BLANK)) {
26600                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26601                            }
26602                            else {
26603                                    bindArticleId = true;
26604    
26605                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26606                            }
26607    
26608                            conjunctionable = true;
26609    
26610                            if ((statuses == null) || (statuses.length > 0)) {
26611                                    if (conjunctionable) {
26612                                            query.append(WHERE_AND);
26613                                    }
26614    
26615                                    query.append(StringPool.OPEN_PARENTHESIS);
26616    
26617                                    for (int i = 0; i < statuses.length; i++) {
26618                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26619    
26620                                            if ((i + 1) < statuses.length) {
26621                                                    query.append(WHERE_OR);
26622                                            }
26623                                    }
26624    
26625                                    query.append(StringPool.CLOSE_PARENTHESIS);
26626    
26627                                    conjunctionable = true;
26628                            }
26629    
26630                            String sql = query.toString();
26631    
26632                            Session session = null;
26633    
26634                            try {
26635                                    session = openSession();
26636    
26637                                    Query q = session.createQuery(sql);
26638    
26639                                    QueryPos qPos = QueryPos.getInstance(q);
26640    
26641                                    qPos.add(groupId);
26642    
26643                                    if (bindArticleId) {
26644                                            qPos.add(articleId);
26645                                    }
26646    
26647                                    if (statuses != null) {
26648                                            qPos.add(statuses);
26649                                    }
26650    
26651                                    count = (Long)q.uniqueResult();
26652    
26653                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
26654                                            finderArgs, count);
26655                            }
26656                            catch (Exception e) {
26657                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
26658                                            finderArgs);
26659    
26660                                    throw processException(e);
26661                            }
26662                            finally {
26663                                    closeSession(session);
26664                            }
26665                    }
26666    
26667                    return count.intValue();
26668            }
26669    
26670            /**
26671             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
26672             *
26673             * @param groupId the group ID
26674             * @param articleId the article ID
26675             * @param status the status
26676             * @return the number of matching journal articles that the user has permission to view
26677             * @throws SystemException if a system exception occurred
26678             */
26679            @Override
26680            public int filterCountByG_A_ST(long groupId, String articleId, int status)
26681                    throws SystemException {
26682                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26683                            return countByG_A_ST(groupId, articleId, status);
26684                    }
26685    
26686                    StringBundler query = new StringBundler(4);
26687    
26688                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26689    
26690                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
26691    
26692                    boolean bindArticleId = false;
26693    
26694                    if (articleId == null) {
26695                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
26696                    }
26697                    else if (articleId.equals(StringPool.BLANK)) {
26698                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
26699                    }
26700                    else {
26701                            bindArticleId = true;
26702    
26703                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
26704                    }
26705    
26706                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
26707    
26708                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26709                                    JournalArticle.class.getName(),
26710                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26711    
26712                    Session session = null;
26713    
26714                    try {
26715                            session = openSession();
26716    
26717                            SQLQuery q = session.createSQLQuery(sql);
26718    
26719                            q.addScalar(COUNT_COLUMN_NAME,
26720                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26721    
26722                            QueryPos qPos = QueryPos.getInstance(q);
26723    
26724                            qPos.add(groupId);
26725    
26726                            if (bindArticleId) {
26727                                    qPos.add(articleId);
26728                            }
26729    
26730                            qPos.add(status);
26731    
26732                            Long count = (Long)q.uniqueResult();
26733    
26734                            return count.intValue();
26735                    }
26736                    catch (Exception e) {
26737                            throw processException(e);
26738                    }
26739                    finally {
26740                            closeSession(session);
26741                    }
26742            }
26743    
26744            /**
26745             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
26746             *
26747             * @param groupId the group ID
26748             * @param articleId the article ID
26749             * @param statuses the statuses
26750             * @return the number of matching journal articles that the user has permission to view
26751             * @throws SystemException if a system exception occurred
26752             */
26753            @Override
26754            public int filterCountByG_A_ST(long groupId, String articleId,
26755                    int[] statuses) throws SystemException {
26756                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26757                            return countByG_A_ST(groupId, articleId, statuses);
26758                    }
26759    
26760                    StringBundler query = new StringBundler();
26761    
26762                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26763    
26764                    boolean conjunctionable = false;
26765    
26766                    if (conjunctionable) {
26767                            query.append(WHERE_AND);
26768                    }
26769    
26770                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26771    
26772                    conjunctionable = true;
26773    
26774                    if (conjunctionable) {
26775                            query.append(WHERE_AND);
26776                    }
26777    
26778                    boolean bindArticleId = false;
26779    
26780                    if (articleId == null) {
26781                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26782                    }
26783                    else if (articleId.equals(StringPool.BLANK)) {
26784                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26785                    }
26786                    else {
26787                            bindArticleId = true;
26788    
26789                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26790                    }
26791    
26792                    conjunctionable = true;
26793    
26794                    if ((statuses == null) || (statuses.length > 0)) {
26795                            if (conjunctionable) {
26796                                    query.append(WHERE_AND);
26797                            }
26798    
26799                            query.append(StringPool.OPEN_PARENTHESIS);
26800    
26801                            for (int i = 0; i < statuses.length; i++) {
26802                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26803    
26804                                    if ((i + 1) < statuses.length) {
26805                                            query.append(WHERE_OR);
26806                                    }
26807                            }
26808    
26809                            query.append(StringPool.CLOSE_PARENTHESIS);
26810    
26811                            conjunctionable = true;
26812                    }
26813    
26814                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26815                                    JournalArticle.class.getName(),
26816                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26817    
26818                    Session session = null;
26819    
26820                    try {
26821                            session = openSession();
26822    
26823                            SQLQuery q = session.createSQLQuery(sql);
26824    
26825                            q.addScalar(COUNT_COLUMN_NAME,
26826                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26827    
26828                            QueryPos qPos = QueryPos.getInstance(q);
26829    
26830                            qPos.add(groupId);
26831    
26832                            if (bindArticleId) {
26833                                    qPos.add(articleId);
26834                            }
26835    
26836                            if (statuses != null) {
26837                                    qPos.add(statuses);
26838                            }
26839    
26840                            Long count = (Long)q.uniqueResult();
26841    
26842                            return count.intValue();
26843                    }
26844                    catch (Exception e) {
26845                            throw processException(e);
26846                    }
26847                    finally {
26848                            closeSession(session);
26849                    }
26850            }
26851    
26852            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
26853            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
26854                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
26855            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
26856            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
26857            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
26858            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
26859                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
26860            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
26861                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
26862            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
26863                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
26864            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
26865            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
26866                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
26867            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST =
26868                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26869                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26870                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
26871                            "findByG_A_NotST",
26872                            new String[] {
26873                                    Long.class.getName(), String.class.getName(),
26874                                    Integer.class.getName(),
26875                                    
26876                            Integer.class.getName(), Integer.class.getName(),
26877                                    OrderByComparator.class.getName()
26878                            });
26879            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST =
26880                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26881                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26882                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_NotST",
26883                            new String[] {
26884                                    Long.class.getName(), String.class.getName(),
26885                                    Integer.class.getName()
26886                            });
26887    
26888            /**
26889             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26890             *
26891             * @param groupId the group ID
26892             * @param articleId the article ID
26893             * @param status the status
26894             * @return the matching journal articles
26895             * @throws SystemException if a system exception occurred
26896             */
26897            @Override
26898            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26899                    int status) throws SystemException {
26900                    return findByG_A_NotST(groupId, articleId, status, QueryUtil.ALL_POS,
26901                            QueryUtil.ALL_POS, null);
26902            }
26903    
26904            /**
26905             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26906             *
26907             * <p>
26908             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26909             * </p>
26910             *
26911             * @param groupId the group ID
26912             * @param articleId the article ID
26913             * @param status the status
26914             * @param start the lower bound of the range of journal articles
26915             * @param end the upper bound of the range of journal articles (not inclusive)
26916             * @return the range of matching journal articles
26917             * @throws SystemException if a system exception occurred
26918             */
26919            @Override
26920            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26921                    int status, int start, int end) throws SystemException {
26922                    return findByG_A_NotST(groupId, articleId, status, start, end, null);
26923            }
26924    
26925            /**
26926             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26927             *
26928             * <p>
26929             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26930             * </p>
26931             *
26932             * @param groupId the group ID
26933             * @param articleId the article ID
26934             * @param status the status
26935             * @param start the lower bound of the range of journal articles
26936             * @param end the upper bound of the range of journal articles (not inclusive)
26937             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26938             * @return the ordered range of matching journal articles
26939             * @throws SystemException if a system exception occurred
26940             */
26941            @Override
26942            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26943                    int status, int start, int end, OrderByComparator orderByComparator)
26944                    throws SystemException {
26945                    boolean pagination = true;
26946                    FinderPath finderPath = null;
26947                    Object[] finderArgs = null;
26948    
26949                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST;
26950                    finderArgs = new Object[] {
26951                                    groupId, articleId, status,
26952                                    
26953                                    start, end, orderByComparator
26954                            };
26955    
26956                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26957                                    finderArgs, this);
26958    
26959                    if ((list != null) && !list.isEmpty()) {
26960                            for (JournalArticle journalArticle : list) {
26961                                    if ((groupId != journalArticle.getGroupId()) ||
26962                                                    !Validator.equals(articleId,
26963                                                            journalArticle.getArticleId()) ||
26964                                                    (status == journalArticle.getStatus())) {
26965                                            list = null;
26966    
26967                                            break;
26968                                    }
26969                            }
26970                    }
26971    
26972                    if (list == null) {
26973                            StringBundler query = null;
26974    
26975                            if (orderByComparator != null) {
26976                                    query = new StringBundler(5 +
26977                                                    (orderByComparator.getOrderByFields().length * 3));
26978                            }
26979                            else {
26980                                    query = new StringBundler(5);
26981                            }
26982    
26983                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26984    
26985                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26986    
26987                            boolean bindArticleId = false;
26988    
26989                            if (articleId == null) {
26990                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26991                            }
26992                            else if (articleId.equals(StringPool.BLANK)) {
26993                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26994                            }
26995                            else {
26996                                    bindArticleId = true;
26997    
26998                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26999                            }
27000    
27001                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27002    
27003                            if (orderByComparator != null) {
27004                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27005                                            orderByComparator);
27006                            }
27007                            else
27008                             if (pagination) {
27009                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27010                            }
27011    
27012                            String sql = query.toString();
27013    
27014                            Session session = null;
27015    
27016                            try {
27017                                    session = openSession();
27018    
27019                                    Query q = session.createQuery(sql);
27020    
27021                                    QueryPos qPos = QueryPos.getInstance(q);
27022    
27023                                    qPos.add(groupId);
27024    
27025                                    if (bindArticleId) {
27026                                            qPos.add(articleId);
27027                                    }
27028    
27029                                    qPos.add(status);
27030    
27031                                    if (!pagination) {
27032                                            list = (List<JournalArticle>)QueryUtil.list(q,
27033                                                            getDialect(), start, end, false);
27034    
27035                                            Collections.sort(list);
27036    
27037                                            list = new UnmodifiableList<JournalArticle>(list);
27038                                    }
27039                                    else {
27040                                            list = (List<JournalArticle>)QueryUtil.list(q,
27041                                                            getDialect(), start, end);
27042                                    }
27043    
27044                                    cacheResult(list);
27045    
27046                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
27047                            }
27048                            catch (Exception e) {
27049                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27050    
27051                                    throw processException(e);
27052                            }
27053                            finally {
27054                                    closeSession(session);
27055                            }
27056                    }
27057    
27058                    return list;
27059            }
27060    
27061            /**
27062             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27063             *
27064             * @param groupId the group ID
27065             * @param articleId the article ID
27066             * @param status the status
27067             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27068             * @return the first matching journal article
27069             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27070             * @throws SystemException if a system exception occurred
27071             */
27072            @Override
27073            public JournalArticle findByG_A_NotST_First(long groupId, String articleId,
27074                    int status, OrderByComparator orderByComparator)
27075                    throws NoSuchArticleException, SystemException {
27076                    JournalArticle journalArticle = fetchByG_A_NotST_First(groupId,
27077                                    articleId, status, orderByComparator);
27078    
27079                    if (journalArticle != null) {
27080                            return journalArticle;
27081                    }
27082    
27083                    StringBundler msg = new StringBundler(8);
27084    
27085                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27086    
27087                    msg.append("groupId=");
27088                    msg.append(groupId);
27089    
27090                    msg.append(", articleId=");
27091                    msg.append(articleId);
27092    
27093                    msg.append(", status=");
27094                    msg.append(status);
27095    
27096                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27097    
27098                    throw new NoSuchArticleException(msg.toString());
27099            }
27100    
27101            /**
27102             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27103             *
27104             * @param groupId the group ID
27105             * @param articleId the article ID
27106             * @param status the status
27107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27108             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
27109             * @throws SystemException if a system exception occurred
27110             */
27111            @Override
27112            public JournalArticle fetchByG_A_NotST_First(long groupId,
27113                    String articleId, int status, OrderByComparator orderByComparator)
27114                    throws SystemException {
27115                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
27116                                    0, 1, orderByComparator);
27117    
27118                    if (!list.isEmpty()) {
27119                            return list.get(0);
27120                    }
27121    
27122                    return null;
27123            }
27124    
27125            /**
27126             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27127             *
27128             * @param groupId the group ID
27129             * @param articleId the article ID
27130             * @param status the status
27131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27132             * @return the last matching journal article
27133             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27134             * @throws SystemException if a system exception occurred
27135             */
27136            @Override
27137            public JournalArticle findByG_A_NotST_Last(long groupId, String articleId,
27138                    int status, OrderByComparator orderByComparator)
27139                    throws NoSuchArticleException, SystemException {
27140                    JournalArticle journalArticle = fetchByG_A_NotST_Last(groupId,
27141                                    articleId, status, orderByComparator);
27142    
27143                    if (journalArticle != null) {
27144                            return journalArticle;
27145                    }
27146    
27147                    StringBundler msg = new StringBundler(8);
27148    
27149                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27150    
27151                    msg.append("groupId=");
27152                    msg.append(groupId);
27153    
27154                    msg.append(", articleId=");
27155                    msg.append(articleId);
27156    
27157                    msg.append(", status=");
27158                    msg.append(status);
27159    
27160                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27161    
27162                    throw new NoSuchArticleException(msg.toString());
27163            }
27164    
27165            /**
27166             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27167             *
27168             * @param groupId the group ID
27169             * @param articleId the article ID
27170             * @param status the status
27171             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27172             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
27173             * @throws SystemException if a system exception occurred
27174             */
27175            @Override
27176            public JournalArticle fetchByG_A_NotST_Last(long groupId, String articleId,
27177                    int status, OrderByComparator orderByComparator)
27178                    throws SystemException {
27179                    int count = countByG_A_NotST(groupId, articleId, status);
27180    
27181                    if (count == 0) {
27182                            return null;
27183                    }
27184    
27185                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
27186                                    count - 1, count, orderByComparator);
27187    
27188                    if (!list.isEmpty()) {
27189                            return list.get(0);
27190                    }
27191    
27192                    return null;
27193            }
27194    
27195            /**
27196             * 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;.
27197             *
27198             * @param id the primary key of the current journal article
27199             * @param groupId the group ID
27200             * @param articleId the article ID
27201             * @param status the status
27202             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27203             * @return the previous, current, and next journal article
27204             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27205             * @throws SystemException if a system exception occurred
27206             */
27207            @Override
27208            public JournalArticle[] findByG_A_NotST_PrevAndNext(long id, long groupId,
27209                    String articleId, int status, OrderByComparator orderByComparator)
27210                    throws NoSuchArticleException, SystemException {
27211                    JournalArticle journalArticle = findByPrimaryKey(id);
27212    
27213                    Session session = null;
27214    
27215                    try {
27216                            session = openSession();
27217    
27218                            JournalArticle[] array = new JournalArticleImpl[3];
27219    
27220                            array[0] = getByG_A_NotST_PrevAndNext(session, journalArticle,
27221                                            groupId, articleId, status, orderByComparator, true);
27222    
27223                            array[1] = journalArticle;
27224    
27225                            array[2] = getByG_A_NotST_PrevAndNext(session, journalArticle,
27226                                            groupId, articleId, status, orderByComparator, false);
27227    
27228                            return array;
27229                    }
27230                    catch (Exception e) {
27231                            throw processException(e);
27232                    }
27233                    finally {
27234                            closeSession(session);
27235                    }
27236            }
27237    
27238            protected JournalArticle getByG_A_NotST_PrevAndNext(Session session,
27239                    JournalArticle journalArticle, long groupId, String articleId,
27240                    int status, OrderByComparator orderByComparator, boolean previous) {
27241                    StringBundler query = null;
27242    
27243                    if (orderByComparator != null) {
27244                            query = new StringBundler(6 +
27245                                            (orderByComparator.getOrderByFields().length * 6));
27246                    }
27247                    else {
27248                            query = new StringBundler(3);
27249                    }
27250    
27251                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27252    
27253                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27254    
27255                    boolean bindArticleId = false;
27256    
27257                    if (articleId == null) {
27258                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27259                    }
27260                    else if (articleId.equals(StringPool.BLANK)) {
27261                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27262                    }
27263                    else {
27264                            bindArticleId = true;
27265    
27266                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27267                    }
27268    
27269                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27270    
27271                    if (orderByComparator != null) {
27272                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27273    
27274                            if (orderByConditionFields.length > 0) {
27275                                    query.append(WHERE_AND);
27276                            }
27277    
27278                            for (int i = 0; i < orderByConditionFields.length; i++) {
27279                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27280                                    query.append(orderByConditionFields[i]);
27281    
27282                                    if ((i + 1) < orderByConditionFields.length) {
27283                                            if (orderByComparator.isAscending() ^ previous) {
27284                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27285                                            }
27286                                            else {
27287                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27288                                            }
27289                                    }
27290                                    else {
27291                                            if (orderByComparator.isAscending() ^ previous) {
27292                                                    query.append(WHERE_GREATER_THAN);
27293                                            }
27294                                            else {
27295                                                    query.append(WHERE_LESSER_THAN);
27296                                            }
27297                                    }
27298                            }
27299    
27300                            query.append(ORDER_BY_CLAUSE);
27301    
27302                            String[] orderByFields = orderByComparator.getOrderByFields();
27303    
27304                            for (int i = 0; i < orderByFields.length; i++) {
27305                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27306                                    query.append(orderByFields[i]);
27307    
27308                                    if ((i + 1) < orderByFields.length) {
27309                                            if (orderByComparator.isAscending() ^ previous) {
27310                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27311                                            }
27312                                            else {
27313                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27314                                            }
27315                                    }
27316                                    else {
27317                                            if (orderByComparator.isAscending() ^ previous) {
27318                                                    query.append(ORDER_BY_ASC);
27319                                            }
27320                                            else {
27321                                                    query.append(ORDER_BY_DESC);
27322                                            }
27323                                    }
27324                            }
27325                    }
27326                    else {
27327                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27328                    }
27329    
27330                    String sql = query.toString();
27331    
27332                    Query q = session.createQuery(sql);
27333    
27334                    q.setFirstResult(0);
27335                    q.setMaxResults(2);
27336    
27337                    QueryPos qPos = QueryPos.getInstance(q);
27338    
27339                    qPos.add(groupId);
27340    
27341                    if (bindArticleId) {
27342                            qPos.add(articleId);
27343                    }
27344    
27345                    qPos.add(status);
27346    
27347                    if (orderByComparator != null) {
27348                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27349    
27350                            for (Object value : values) {
27351                                    qPos.add(value);
27352                            }
27353                    }
27354    
27355                    List<JournalArticle> list = q.list();
27356    
27357                    if (list.size() == 2) {
27358                            return list.get(1);
27359                    }
27360                    else {
27361                            return null;
27362                    }
27363            }
27364    
27365            /**
27366             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27367             *
27368             * @param groupId the group ID
27369             * @param articleId the article ID
27370             * @param status the status
27371             * @return the matching journal articles that the user has permission to view
27372             * @throws SystemException if a system exception occurred
27373             */
27374            @Override
27375            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
27376                    String articleId, int status) throws SystemException {
27377                    return filterFindByG_A_NotST(groupId, articleId, status,
27378                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27379            }
27380    
27381            /**
27382             * 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;.
27383             *
27384             * <p>
27385             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27386             * </p>
27387             *
27388             * @param groupId the group ID
27389             * @param articleId the article ID
27390             * @param status the status
27391             * @param start the lower bound of the range of journal articles
27392             * @param end the upper bound of the range of journal articles (not inclusive)
27393             * @return the range of matching journal articles that the user has permission to view
27394             * @throws SystemException if a system exception occurred
27395             */
27396            @Override
27397            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
27398                    String articleId, int status, int start, int end)
27399                    throws SystemException {
27400                    return filterFindByG_A_NotST(groupId, articleId, status, start, end,
27401                            null);
27402            }
27403    
27404            /**
27405             * 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;.
27406             *
27407             * <p>
27408             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27409             * </p>
27410             *
27411             * @param groupId the group ID
27412             * @param articleId the article ID
27413             * @param status the status
27414             * @param start the lower bound of the range of journal articles
27415             * @param end the upper bound of the range of journal articles (not inclusive)
27416             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27417             * @return the ordered range of matching journal articles that the user has permission to view
27418             * @throws SystemException if a system exception occurred
27419             */
27420            @Override
27421            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
27422                    String articleId, int status, int start, int end,
27423                    OrderByComparator orderByComparator) throws SystemException {
27424                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27425                            return findByG_A_NotST(groupId, articleId, status, start, end,
27426                                    orderByComparator);
27427                    }
27428    
27429                    StringBundler query = null;
27430    
27431                    if (orderByComparator != null) {
27432                            query = new StringBundler(5 +
27433                                            (orderByComparator.getOrderByFields().length * 3));
27434                    }
27435                    else {
27436                            query = new StringBundler(5);
27437                    }
27438    
27439                    if (getDB().isSupportsInlineDistinct()) {
27440                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27441                    }
27442                    else {
27443                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27444                    }
27445    
27446                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27447    
27448                    boolean bindArticleId = false;
27449    
27450                    if (articleId == null) {
27451                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27452                    }
27453                    else if (articleId.equals(StringPool.BLANK)) {
27454                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27455                    }
27456                    else {
27457                            bindArticleId = true;
27458    
27459                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27460                    }
27461    
27462                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27463    
27464                    if (!getDB().isSupportsInlineDistinct()) {
27465                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27466                    }
27467    
27468                    if (orderByComparator != null) {
27469                            if (getDB().isSupportsInlineDistinct()) {
27470                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27471                                            orderByComparator, true);
27472                            }
27473                            else {
27474                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
27475                                            orderByComparator, true);
27476                            }
27477                    }
27478                    else {
27479                            if (getDB().isSupportsInlineDistinct()) {
27480                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27481                            }
27482                            else {
27483                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27484                            }
27485                    }
27486    
27487                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27488                                    JournalArticle.class.getName(),
27489                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27490    
27491                    Session session = null;
27492    
27493                    try {
27494                            session = openSession();
27495    
27496                            SQLQuery q = session.createSQLQuery(sql);
27497    
27498                            if (getDB().isSupportsInlineDistinct()) {
27499                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27500                            }
27501                            else {
27502                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27503                            }
27504    
27505                            QueryPos qPos = QueryPos.getInstance(q);
27506    
27507                            qPos.add(groupId);
27508    
27509                            if (bindArticleId) {
27510                                    qPos.add(articleId);
27511                            }
27512    
27513                            qPos.add(status);
27514    
27515                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
27516                                    end);
27517                    }
27518                    catch (Exception e) {
27519                            throw processException(e);
27520                    }
27521                    finally {
27522                            closeSession(session);
27523                    }
27524            }
27525    
27526            /**
27527             * 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;.
27528             *
27529             * @param id the primary key of the current journal article
27530             * @param groupId the group ID
27531             * @param articleId the article ID
27532             * @param status the status
27533             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27534             * @return the previous, current, and next journal article
27535             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27536             * @throws SystemException if a system exception occurred
27537             */
27538            @Override
27539            public JournalArticle[] filterFindByG_A_NotST_PrevAndNext(long id,
27540                    long groupId, String articleId, int status,
27541                    OrderByComparator orderByComparator)
27542                    throws NoSuchArticleException, SystemException {
27543                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27544                            return findByG_A_NotST_PrevAndNext(id, groupId, articleId, status,
27545                                    orderByComparator);
27546                    }
27547    
27548                    JournalArticle journalArticle = findByPrimaryKey(id);
27549    
27550                    Session session = null;
27551    
27552                    try {
27553                            session = openSession();
27554    
27555                            JournalArticle[] array = new JournalArticleImpl[3];
27556    
27557                            array[0] = filterGetByG_A_NotST_PrevAndNext(session,
27558                                            journalArticle, groupId, articleId, status,
27559                                            orderByComparator, true);
27560    
27561                            array[1] = journalArticle;
27562    
27563                            array[2] = filterGetByG_A_NotST_PrevAndNext(session,
27564                                            journalArticle, groupId, articleId, status,
27565                                            orderByComparator, false);
27566    
27567                            return array;
27568                    }
27569                    catch (Exception e) {
27570                            throw processException(e);
27571                    }
27572                    finally {
27573                            closeSession(session);
27574                    }
27575            }
27576    
27577            protected JournalArticle filterGetByG_A_NotST_PrevAndNext(Session session,
27578                    JournalArticle journalArticle, long groupId, String articleId,
27579                    int status, OrderByComparator orderByComparator, boolean previous) {
27580                    StringBundler query = null;
27581    
27582                    if (orderByComparator != null) {
27583                            query = new StringBundler(6 +
27584                                            (orderByComparator.getOrderByFields().length * 6));
27585                    }
27586                    else {
27587                            query = new StringBundler(3);
27588                    }
27589    
27590                    if (getDB().isSupportsInlineDistinct()) {
27591                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27592                    }
27593                    else {
27594                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27595                    }
27596    
27597                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27598    
27599                    boolean bindArticleId = false;
27600    
27601                    if (articleId == null) {
27602                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27603                    }
27604                    else if (articleId.equals(StringPool.BLANK)) {
27605                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27606                    }
27607                    else {
27608                            bindArticleId = true;
27609    
27610                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27611                    }
27612    
27613                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27614    
27615                    if (!getDB().isSupportsInlineDistinct()) {
27616                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27617                    }
27618    
27619                    if (orderByComparator != null) {
27620                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27621    
27622                            if (orderByConditionFields.length > 0) {
27623                                    query.append(WHERE_AND);
27624                            }
27625    
27626                            for (int i = 0; i < orderByConditionFields.length; i++) {
27627                                    if (getDB().isSupportsInlineDistinct()) {
27628                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27629                                    }
27630                                    else {
27631                                            query.append(_ORDER_BY_ENTITY_TABLE);
27632                                    }
27633    
27634                                    query.append(orderByConditionFields[i]);
27635    
27636                                    if ((i + 1) < orderByConditionFields.length) {
27637                                            if (orderByComparator.isAscending() ^ previous) {
27638                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27639                                            }
27640                                            else {
27641                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27642                                            }
27643                                    }
27644                                    else {
27645                                            if (orderByComparator.isAscending() ^ previous) {
27646                                                    query.append(WHERE_GREATER_THAN);
27647                                            }
27648                                            else {
27649                                                    query.append(WHERE_LESSER_THAN);
27650                                            }
27651                                    }
27652                            }
27653    
27654                            query.append(ORDER_BY_CLAUSE);
27655    
27656                            String[] orderByFields = orderByComparator.getOrderByFields();
27657    
27658                            for (int i = 0; i < orderByFields.length; i++) {
27659                                    if (getDB().isSupportsInlineDistinct()) {
27660                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27661                                    }
27662                                    else {
27663                                            query.append(_ORDER_BY_ENTITY_TABLE);
27664                                    }
27665    
27666                                    query.append(orderByFields[i]);
27667    
27668                                    if ((i + 1) < orderByFields.length) {
27669                                            if (orderByComparator.isAscending() ^ previous) {
27670                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27671                                            }
27672                                            else {
27673                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27674                                            }
27675                                    }
27676                                    else {
27677                                            if (orderByComparator.isAscending() ^ previous) {
27678                                                    query.append(ORDER_BY_ASC);
27679                                            }
27680                                            else {
27681                                                    query.append(ORDER_BY_DESC);
27682                                            }
27683                                    }
27684                            }
27685                    }
27686                    else {
27687                            if (getDB().isSupportsInlineDistinct()) {
27688                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27689                            }
27690                            else {
27691                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27692                            }
27693                    }
27694    
27695                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27696                                    JournalArticle.class.getName(),
27697                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27698    
27699                    SQLQuery q = session.createSQLQuery(sql);
27700    
27701                    q.setFirstResult(0);
27702                    q.setMaxResults(2);
27703    
27704                    if (getDB().isSupportsInlineDistinct()) {
27705                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27706                    }
27707                    else {
27708                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27709                    }
27710    
27711                    QueryPos qPos = QueryPos.getInstance(q);
27712    
27713                    qPos.add(groupId);
27714    
27715                    if (bindArticleId) {
27716                            qPos.add(articleId);
27717                    }
27718    
27719                    qPos.add(status);
27720    
27721                    if (orderByComparator != null) {
27722                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27723    
27724                            for (Object value : values) {
27725                                    qPos.add(value);
27726                            }
27727                    }
27728    
27729                    List<JournalArticle> list = q.list();
27730    
27731                    if (list.size() == 2) {
27732                            return list.get(1);
27733                    }
27734                    else {
27735                            return null;
27736                    }
27737            }
27738    
27739            /**
27740             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63; from the database.
27741             *
27742             * @param groupId the group ID
27743             * @param articleId the article ID
27744             * @param status the status
27745             * @throws SystemException if a system exception occurred
27746             */
27747            @Override
27748            public void removeByG_A_NotST(long groupId, String articleId, int status)
27749                    throws SystemException {
27750                    for (JournalArticle journalArticle : findByG_A_NotST(groupId,
27751                                    articleId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
27752                            remove(journalArticle);
27753                    }
27754            }
27755    
27756            /**
27757             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27758             *
27759             * @param groupId the group ID
27760             * @param articleId the article ID
27761             * @param status the status
27762             * @return the number of matching journal articles
27763             * @throws SystemException if a system exception occurred
27764             */
27765            @Override
27766            public int countByG_A_NotST(long groupId, String articleId, int status)
27767                    throws SystemException {
27768                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST;
27769    
27770                    Object[] finderArgs = new Object[] { groupId, articleId, status };
27771    
27772                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
27773                                    this);
27774    
27775                    if (count == null) {
27776                            StringBundler query = new StringBundler(4);
27777    
27778                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
27779    
27780                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27781    
27782                            boolean bindArticleId = false;
27783    
27784                            if (articleId == null) {
27785                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27786                            }
27787                            else if (articleId.equals(StringPool.BLANK)) {
27788                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27789                            }
27790                            else {
27791                                    bindArticleId = true;
27792    
27793                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27794                            }
27795    
27796                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27797    
27798                            String sql = query.toString();
27799    
27800                            Session session = null;
27801    
27802                            try {
27803                                    session = openSession();
27804    
27805                                    Query q = session.createQuery(sql);
27806    
27807                                    QueryPos qPos = QueryPos.getInstance(q);
27808    
27809                                    qPos.add(groupId);
27810    
27811                                    if (bindArticleId) {
27812                                            qPos.add(articleId);
27813                                    }
27814    
27815                                    qPos.add(status);
27816    
27817                                    count = (Long)q.uniqueResult();
27818    
27819                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
27820                            }
27821                            catch (Exception e) {
27822                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27823    
27824                                    throw processException(e);
27825                            }
27826                            finally {
27827                                    closeSession(session);
27828                            }
27829                    }
27830    
27831                    return count.intValue();
27832            }
27833    
27834            /**
27835             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27836             *
27837             * @param groupId the group ID
27838             * @param articleId the article ID
27839             * @param status the status
27840             * @return the number of matching journal articles that the user has permission to view
27841             * @throws SystemException if a system exception occurred
27842             */
27843            @Override
27844            public int filterCountByG_A_NotST(long groupId, String articleId, int status)
27845                    throws SystemException {
27846                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27847                            return countByG_A_NotST(groupId, articleId, status);
27848                    }
27849    
27850                    StringBundler query = new StringBundler(4);
27851    
27852                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
27853    
27854                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27855    
27856                    boolean bindArticleId = false;
27857    
27858                    if (articleId == null) {
27859                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27860                    }
27861                    else if (articleId.equals(StringPool.BLANK)) {
27862                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27863                    }
27864                    else {
27865                            bindArticleId = true;
27866    
27867                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27868                    }
27869    
27870                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27871    
27872                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27873                                    JournalArticle.class.getName(),
27874                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27875    
27876                    Session session = null;
27877    
27878                    try {
27879                            session = openSession();
27880    
27881                            SQLQuery q = session.createSQLQuery(sql);
27882    
27883                            q.addScalar(COUNT_COLUMN_NAME,
27884                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
27885    
27886                            QueryPos qPos = QueryPos.getInstance(q);
27887    
27888                            qPos.add(groupId);
27889    
27890                            if (bindArticleId) {
27891                                    qPos.add(articleId);
27892                            }
27893    
27894                            qPos.add(status);
27895    
27896                            Long count = (Long)q.uniqueResult();
27897    
27898                            return count.intValue();
27899                    }
27900                    catch (Exception e) {
27901                            throw processException(e);
27902                    }
27903                    finally {
27904                            closeSession(session);
27905                    }
27906            }
27907    
27908            private static final String _FINDER_COLUMN_G_A_NOTST_GROUPID_2 = "journalArticle.groupId = ? AND ";
27909            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
27910            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
27911            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
27912            private static final String _FINDER_COLUMN_G_A_NOTST_STATUS_2 = "journalArticle.status != ?";
27913            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27914                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27915                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
27916                            "findByG_UT_ST",
27917                            new String[] {
27918                                    Long.class.getName(), String.class.getName(),
27919                                    Integer.class.getName(),
27920                                    
27921                            Integer.class.getName(), Integer.class.getName(),
27922                                    OrderByComparator.class.getName()
27923                            });
27924            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
27925                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27926                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27927                            JournalArticleImpl.class,
27928                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
27929                            new String[] {
27930                                    Long.class.getName(), String.class.getName(),
27931                                    Integer.class.getName()
27932                            },
27933                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
27934                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
27935                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
27936                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
27937                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
27938            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27939                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
27940                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
27941                            new String[] {
27942                                    Long.class.getName(), String.class.getName(),
27943                                    Integer.class.getName()
27944                            });
27945    
27946            /**
27947             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27948             *
27949             * @param groupId the group ID
27950             * @param urlTitle the url title
27951             * @param status the status
27952             * @return the matching journal articles
27953             * @throws SystemException if a system exception occurred
27954             */
27955            @Override
27956            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27957                    int status) throws SystemException {
27958                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
27959                            QueryUtil.ALL_POS, null);
27960            }
27961    
27962            /**
27963             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27964             *
27965             * <p>
27966             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27967             * </p>
27968             *
27969             * @param groupId the group ID
27970             * @param urlTitle the url title
27971             * @param status the status
27972             * @param start the lower bound of the range of journal articles
27973             * @param end the upper bound of the range of journal articles (not inclusive)
27974             * @return the range of matching journal articles
27975             * @throws SystemException if a system exception occurred
27976             */
27977            @Override
27978            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27979                    int status, int start, int end) throws SystemException {
27980                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
27981            }
27982    
27983            /**
27984             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27985             *
27986             * <p>
27987             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27988             * </p>
27989             *
27990             * @param groupId the group ID
27991             * @param urlTitle the url title
27992             * @param status the status
27993             * @param start the lower bound of the range of journal articles
27994             * @param end the upper bound of the range of journal articles (not inclusive)
27995             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27996             * @return the ordered range of matching journal articles
27997             * @throws SystemException if a system exception occurred
27998             */
27999            @Override
28000            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
28001                    int status, int start, int end, OrderByComparator orderByComparator)
28002                    throws SystemException {
28003                    boolean pagination = true;
28004                    FinderPath finderPath = null;
28005                    Object[] finderArgs = null;
28006    
28007                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
28008                                    (orderByComparator == null)) {
28009                            pagination = false;
28010                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
28011                            finderArgs = new Object[] { groupId, urlTitle, status };
28012                    }
28013                    else {
28014                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
28015                            finderArgs = new Object[] {
28016                                            groupId, urlTitle, status,
28017                                            
28018                                            start, end, orderByComparator
28019                                    };
28020                    }
28021    
28022                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
28023                                    finderArgs, this);
28024    
28025                    if ((list != null) && !list.isEmpty()) {
28026                            for (JournalArticle journalArticle : list) {
28027                                    if ((groupId != journalArticle.getGroupId()) ||
28028                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
28029                                                    (status != journalArticle.getStatus())) {
28030                                            list = null;
28031    
28032                                            break;
28033                                    }
28034                            }
28035                    }
28036    
28037                    if (list == null) {
28038                            StringBundler query = null;
28039    
28040                            if (orderByComparator != null) {
28041                                    query = new StringBundler(5 +
28042                                                    (orderByComparator.getOrderByFields().length * 3));
28043                            }
28044                            else {
28045                                    query = new StringBundler(5);
28046                            }
28047    
28048                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28049    
28050                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28051    
28052                            boolean bindUrlTitle = false;
28053    
28054                            if (urlTitle == null) {
28055                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28056                            }
28057                            else if (urlTitle.equals(StringPool.BLANK)) {
28058                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28059                            }
28060                            else {
28061                                    bindUrlTitle = true;
28062    
28063                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28064                            }
28065    
28066                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28067    
28068                            if (orderByComparator != null) {
28069                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28070                                            orderByComparator);
28071                            }
28072                            else
28073                             if (pagination) {
28074                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28075                            }
28076    
28077                            String sql = query.toString();
28078    
28079                            Session session = null;
28080    
28081                            try {
28082                                    session = openSession();
28083    
28084                                    Query q = session.createQuery(sql);
28085    
28086                                    QueryPos qPos = QueryPos.getInstance(q);
28087    
28088                                    qPos.add(groupId);
28089    
28090                                    if (bindUrlTitle) {
28091                                            qPos.add(urlTitle);
28092                                    }
28093    
28094                                    qPos.add(status);
28095    
28096                                    if (!pagination) {
28097                                            list = (List<JournalArticle>)QueryUtil.list(q,
28098                                                            getDialect(), start, end, false);
28099    
28100                                            Collections.sort(list);
28101    
28102                                            list = new UnmodifiableList<JournalArticle>(list);
28103                                    }
28104                                    else {
28105                                            list = (List<JournalArticle>)QueryUtil.list(q,
28106                                                            getDialect(), start, end);
28107                                    }
28108    
28109                                    cacheResult(list);
28110    
28111                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
28112                            }
28113                            catch (Exception e) {
28114                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28115    
28116                                    throw processException(e);
28117                            }
28118                            finally {
28119                                    closeSession(session);
28120                            }
28121                    }
28122    
28123                    return list;
28124            }
28125    
28126            /**
28127             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28128             *
28129             * @param groupId the group ID
28130             * @param urlTitle the url title
28131             * @param status the status
28132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28133             * @return the first matching journal article
28134             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28135             * @throws SystemException if a system exception occurred
28136             */
28137            @Override
28138            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
28139                    int status, OrderByComparator orderByComparator)
28140                    throws NoSuchArticleException, SystemException {
28141                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
28142                                    status, orderByComparator);
28143    
28144                    if (journalArticle != null) {
28145                            return journalArticle;
28146                    }
28147    
28148                    StringBundler msg = new StringBundler(8);
28149    
28150                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28151    
28152                    msg.append("groupId=");
28153                    msg.append(groupId);
28154    
28155                    msg.append(", urlTitle=");
28156                    msg.append(urlTitle);
28157    
28158                    msg.append(", status=");
28159                    msg.append(status);
28160    
28161                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28162    
28163                    throw new NoSuchArticleException(msg.toString());
28164            }
28165    
28166            /**
28167             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28168             *
28169             * @param groupId the group ID
28170             * @param urlTitle the url title
28171             * @param status the status
28172             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28173             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
28174             * @throws SystemException if a system exception occurred
28175             */
28176            @Override
28177            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
28178                    int status, OrderByComparator orderByComparator)
28179                    throws SystemException {
28180                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
28181                                    1, orderByComparator);
28182    
28183                    if (!list.isEmpty()) {
28184                            return list.get(0);
28185                    }
28186    
28187                    return null;
28188            }
28189    
28190            /**
28191             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28192             *
28193             * @param groupId the group ID
28194             * @param urlTitle the url title
28195             * @param status the status
28196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28197             * @return the last matching journal article
28198             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28199             * @throws SystemException if a system exception occurred
28200             */
28201            @Override
28202            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
28203                    int status, OrderByComparator orderByComparator)
28204                    throws NoSuchArticleException, SystemException {
28205                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
28206                                    status, orderByComparator);
28207    
28208                    if (journalArticle != null) {
28209                            return journalArticle;
28210                    }
28211    
28212                    StringBundler msg = new StringBundler(8);
28213    
28214                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28215    
28216                    msg.append("groupId=");
28217                    msg.append(groupId);
28218    
28219                    msg.append(", urlTitle=");
28220                    msg.append(urlTitle);
28221    
28222                    msg.append(", status=");
28223                    msg.append(status);
28224    
28225                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28226    
28227                    throw new NoSuchArticleException(msg.toString());
28228            }
28229    
28230            /**
28231             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28232             *
28233             * @param groupId the group ID
28234             * @param urlTitle the url title
28235             * @param status the status
28236             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28237             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
28238             * @throws SystemException if a system exception occurred
28239             */
28240            @Override
28241            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
28242                    int status, OrderByComparator orderByComparator)
28243                    throws SystemException {
28244                    int count = countByG_UT_ST(groupId, urlTitle, status);
28245    
28246                    if (count == 0) {
28247                            return null;
28248                    }
28249    
28250                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
28251                                    count - 1, count, orderByComparator);
28252    
28253                    if (!list.isEmpty()) {
28254                            return list.get(0);
28255                    }
28256    
28257                    return null;
28258            }
28259    
28260            /**
28261             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28262             *
28263             * @param id the primary key of the current journal article
28264             * @param groupId the group ID
28265             * @param urlTitle the url title
28266             * @param status the status
28267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28268             * @return the previous, current, and next journal article
28269             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28270             * @throws SystemException if a system exception occurred
28271             */
28272            @Override
28273            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
28274                    String urlTitle, int status, OrderByComparator orderByComparator)
28275                    throws NoSuchArticleException, SystemException {
28276                    JournalArticle journalArticle = findByPrimaryKey(id);
28277    
28278                    Session session = null;
28279    
28280                    try {
28281                            session = openSession();
28282    
28283                            JournalArticle[] array = new JournalArticleImpl[3];
28284    
28285                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
28286                                            groupId, urlTitle, status, orderByComparator, true);
28287    
28288                            array[1] = journalArticle;
28289    
28290                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
28291                                            groupId, urlTitle, status, orderByComparator, false);
28292    
28293                            return array;
28294                    }
28295                    catch (Exception e) {
28296                            throw processException(e);
28297                    }
28298                    finally {
28299                            closeSession(session);
28300                    }
28301            }
28302    
28303            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
28304                    JournalArticle journalArticle, long groupId, String urlTitle,
28305                    int status, OrderByComparator orderByComparator, boolean previous) {
28306                    StringBundler query = null;
28307    
28308                    if (orderByComparator != null) {
28309                            query = new StringBundler(6 +
28310                                            (orderByComparator.getOrderByFields().length * 6));
28311                    }
28312                    else {
28313                            query = new StringBundler(3);
28314                    }
28315    
28316                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28317    
28318                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28319    
28320                    boolean bindUrlTitle = false;
28321    
28322                    if (urlTitle == null) {
28323                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28324                    }
28325                    else if (urlTitle.equals(StringPool.BLANK)) {
28326                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28327                    }
28328                    else {
28329                            bindUrlTitle = true;
28330    
28331                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28332                    }
28333    
28334                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28335    
28336                    if (orderByComparator != null) {
28337                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28338    
28339                            if (orderByConditionFields.length > 0) {
28340                                    query.append(WHERE_AND);
28341                            }
28342    
28343                            for (int i = 0; i < orderByConditionFields.length; i++) {
28344                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28345                                    query.append(orderByConditionFields[i]);
28346    
28347                                    if ((i + 1) < orderByConditionFields.length) {
28348                                            if (orderByComparator.isAscending() ^ previous) {
28349                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28350                                            }
28351                                            else {
28352                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28353                                            }
28354                                    }
28355                                    else {
28356                                            if (orderByComparator.isAscending() ^ previous) {
28357                                                    query.append(WHERE_GREATER_THAN);
28358                                            }
28359                                            else {
28360                                                    query.append(WHERE_LESSER_THAN);
28361                                            }
28362                                    }
28363                            }
28364    
28365                            query.append(ORDER_BY_CLAUSE);
28366    
28367                            String[] orderByFields = orderByComparator.getOrderByFields();
28368    
28369                            for (int i = 0; i < orderByFields.length; i++) {
28370                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28371                                    query.append(orderByFields[i]);
28372    
28373                                    if ((i + 1) < orderByFields.length) {
28374                                            if (orderByComparator.isAscending() ^ previous) {
28375                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28376                                            }
28377                                            else {
28378                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28379                                            }
28380                                    }
28381                                    else {
28382                                            if (orderByComparator.isAscending() ^ previous) {
28383                                                    query.append(ORDER_BY_ASC);
28384                                            }
28385                                            else {
28386                                                    query.append(ORDER_BY_DESC);
28387                                            }
28388                                    }
28389                            }
28390                    }
28391                    else {
28392                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28393                    }
28394    
28395                    String sql = query.toString();
28396    
28397                    Query q = session.createQuery(sql);
28398    
28399                    q.setFirstResult(0);
28400                    q.setMaxResults(2);
28401    
28402                    QueryPos qPos = QueryPos.getInstance(q);
28403    
28404                    qPos.add(groupId);
28405    
28406                    if (bindUrlTitle) {
28407                            qPos.add(urlTitle);
28408                    }
28409    
28410                    qPos.add(status);
28411    
28412                    if (orderByComparator != null) {
28413                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28414    
28415                            for (Object value : values) {
28416                                    qPos.add(value);
28417                            }
28418                    }
28419    
28420                    List<JournalArticle> list = q.list();
28421    
28422                    if (list.size() == 2) {
28423                            return list.get(1);
28424                    }
28425                    else {
28426                            return null;
28427                    }
28428            }
28429    
28430            /**
28431             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28432             *
28433             * @param groupId the group ID
28434             * @param urlTitle the url title
28435             * @param status the status
28436             * @return the matching journal articles that the user has permission to view
28437             * @throws SystemException if a system exception occurred
28438             */
28439            @Override
28440            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
28441                    String urlTitle, int status) throws SystemException {
28442                    return filterFindByG_UT_ST(groupId, urlTitle, status,
28443                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
28444            }
28445    
28446            /**
28447             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28448             *
28449             * <p>
28450             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28451             * </p>
28452             *
28453             * @param groupId the group ID
28454             * @param urlTitle the url title
28455             * @param status the status
28456             * @param start the lower bound of the range of journal articles
28457             * @param end the upper bound of the range of journal articles (not inclusive)
28458             * @return the range of matching journal articles that the user has permission to view
28459             * @throws SystemException if a system exception occurred
28460             */
28461            @Override
28462            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
28463                    String urlTitle, int status, int start, int end)
28464                    throws SystemException {
28465                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
28466            }
28467    
28468            /**
28469             * 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;.
28470             *
28471             * <p>
28472             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28473             * </p>
28474             *
28475             * @param groupId the group ID
28476             * @param urlTitle the url title
28477             * @param status the status
28478             * @param start the lower bound of the range of journal articles
28479             * @param end the upper bound of the range of journal articles (not inclusive)
28480             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28481             * @return the ordered range of matching journal articles that the user has permission to view
28482             * @throws SystemException if a system exception occurred
28483             */
28484            @Override
28485            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
28486                    String urlTitle, int status, int start, int end,
28487                    OrderByComparator orderByComparator) throws SystemException {
28488                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28489                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
28490                                    orderByComparator);
28491                    }
28492    
28493                    StringBundler query = null;
28494    
28495                    if (orderByComparator != null) {
28496                            query = new StringBundler(5 +
28497                                            (orderByComparator.getOrderByFields().length * 3));
28498                    }
28499                    else {
28500                            query = new StringBundler(5);
28501                    }
28502    
28503                    if (getDB().isSupportsInlineDistinct()) {
28504                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
28505                    }
28506                    else {
28507                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
28508                    }
28509    
28510                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28511    
28512                    boolean bindUrlTitle = false;
28513    
28514                    if (urlTitle == null) {
28515                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28516                    }
28517                    else if (urlTitle.equals(StringPool.BLANK)) {
28518                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28519                    }
28520                    else {
28521                            bindUrlTitle = true;
28522    
28523                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28524                    }
28525    
28526                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28527    
28528                    if (!getDB().isSupportsInlineDistinct()) {
28529                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
28530                    }
28531    
28532                    if (orderByComparator != null) {
28533                            if (getDB().isSupportsInlineDistinct()) {
28534                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28535                                            orderByComparator, true);
28536                            }
28537                            else {
28538                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
28539                                            orderByComparator, true);
28540                            }
28541                    }
28542                    else {
28543                            if (getDB().isSupportsInlineDistinct()) {
28544                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28545                            }
28546                            else {
28547                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
28548                            }
28549                    }
28550    
28551                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28552                                    JournalArticle.class.getName(),
28553                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28554    
28555                    Session session = null;
28556    
28557                    try {
28558                            session = openSession();
28559    
28560                            SQLQuery q = session.createSQLQuery(sql);
28561    
28562                            if (getDB().isSupportsInlineDistinct()) {
28563                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
28564                            }
28565                            else {
28566                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
28567                            }
28568    
28569                            QueryPos qPos = QueryPos.getInstance(q);
28570    
28571                            qPos.add(groupId);
28572    
28573                            if (bindUrlTitle) {
28574                                    qPos.add(urlTitle);
28575                            }
28576    
28577                            qPos.add(status);
28578    
28579                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
28580                                    end);
28581                    }
28582                    catch (Exception e) {
28583                            throw processException(e);
28584                    }
28585                    finally {
28586                            closeSession(session);
28587                    }
28588            }
28589    
28590            /**
28591             * 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;.
28592             *
28593             * @param id the primary key of the current journal article
28594             * @param groupId the group ID
28595             * @param urlTitle the url title
28596             * @param status the status
28597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28598             * @return the previous, current, and next journal article
28599             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28600             * @throws SystemException if a system exception occurred
28601             */
28602            @Override
28603            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
28604                    long groupId, String urlTitle, int status,
28605                    OrderByComparator orderByComparator)
28606                    throws NoSuchArticleException, SystemException {
28607                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28608                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
28609                                    orderByComparator);
28610                    }
28611    
28612                    JournalArticle journalArticle = findByPrimaryKey(id);
28613    
28614                    Session session = null;
28615    
28616                    try {
28617                            session = openSession();
28618    
28619                            JournalArticle[] array = new JournalArticleImpl[3];
28620    
28621                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
28622                                            groupId, urlTitle, status, orderByComparator, true);
28623    
28624                            array[1] = journalArticle;
28625    
28626                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
28627                                            groupId, urlTitle, status, orderByComparator, false);
28628    
28629                            return array;
28630                    }
28631                    catch (Exception e) {
28632                            throw processException(e);
28633                    }
28634                    finally {
28635                            closeSession(session);
28636                    }
28637            }
28638    
28639            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
28640                    JournalArticle journalArticle, long groupId, String urlTitle,
28641                    int status, OrderByComparator orderByComparator, boolean previous) {
28642                    StringBundler query = null;
28643    
28644                    if (orderByComparator != null) {
28645                            query = new StringBundler(6 +
28646                                            (orderByComparator.getOrderByFields().length * 6));
28647                    }
28648                    else {
28649                            query = new StringBundler(3);
28650                    }
28651    
28652                    if (getDB().isSupportsInlineDistinct()) {
28653                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
28654                    }
28655                    else {
28656                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
28657                    }
28658    
28659                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28660    
28661                    boolean bindUrlTitle = false;
28662    
28663                    if (urlTitle == null) {
28664                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28665                    }
28666                    else if (urlTitle.equals(StringPool.BLANK)) {
28667                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28668                    }
28669                    else {
28670                            bindUrlTitle = true;
28671    
28672                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28673                    }
28674    
28675                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28676    
28677                    if (!getDB().isSupportsInlineDistinct()) {
28678                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
28679                    }
28680    
28681                    if (orderByComparator != null) {
28682                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28683    
28684                            if (orderByConditionFields.length > 0) {
28685                                    query.append(WHERE_AND);
28686                            }
28687    
28688                            for (int i = 0; i < orderByConditionFields.length; i++) {
28689                                    if (getDB().isSupportsInlineDistinct()) {
28690                                            query.append(_ORDER_BY_ENTITY_ALIAS);
28691                                    }
28692                                    else {
28693                                            query.append(_ORDER_BY_ENTITY_TABLE);
28694                                    }
28695    
28696                                    query.append(orderByConditionFields[i]);
28697    
28698                                    if ((i + 1) < orderByConditionFields.length) {
28699                                            if (orderByComparator.isAscending() ^ previous) {
28700                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28701                                            }
28702                                            else {
28703                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28704                                            }
28705                                    }
28706                                    else {
28707                                            if (orderByComparator.isAscending() ^ previous) {
28708                                                    query.append(WHERE_GREATER_THAN);
28709                                            }
28710                                            else {
28711                                                    query.append(WHERE_LESSER_THAN);
28712                                            }
28713                                    }
28714                            }
28715    
28716                            query.append(ORDER_BY_CLAUSE);
28717    
28718                            String[] orderByFields = orderByComparator.getOrderByFields();
28719    
28720                            for (int i = 0; i < orderByFields.length; i++) {
28721                                    if (getDB().isSupportsInlineDistinct()) {
28722                                            query.append(_ORDER_BY_ENTITY_ALIAS);
28723                                    }
28724                                    else {
28725                                            query.append(_ORDER_BY_ENTITY_TABLE);
28726                                    }
28727    
28728                                    query.append(orderByFields[i]);
28729    
28730                                    if ((i + 1) < orderByFields.length) {
28731                                            if (orderByComparator.isAscending() ^ previous) {
28732                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28733                                            }
28734                                            else {
28735                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28736                                            }
28737                                    }
28738                                    else {
28739                                            if (orderByComparator.isAscending() ^ previous) {
28740                                                    query.append(ORDER_BY_ASC);
28741                                            }
28742                                            else {
28743                                                    query.append(ORDER_BY_DESC);
28744                                            }
28745                                    }
28746                            }
28747                    }
28748                    else {
28749                            if (getDB().isSupportsInlineDistinct()) {
28750                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28751                            }
28752                            else {
28753                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
28754                            }
28755                    }
28756    
28757                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28758                                    JournalArticle.class.getName(),
28759                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28760    
28761                    SQLQuery q = session.createSQLQuery(sql);
28762    
28763                    q.setFirstResult(0);
28764                    q.setMaxResults(2);
28765    
28766                    if (getDB().isSupportsInlineDistinct()) {
28767                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
28768                    }
28769                    else {
28770                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
28771                    }
28772    
28773                    QueryPos qPos = QueryPos.getInstance(q);
28774    
28775                    qPos.add(groupId);
28776    
28777                    if (bindUrlTitle) {
28778                            qPos.add(urlTitle);
28779                    }
28780    
28781                    qPos.add(status);
28782    
28783                    if (orderByComparator != null) {
28784                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28785    
28786                            for (Object value : values) {
28787                                    qPos.add(value);
28788                            }
28789                    }
28790    
28791                    List<JournalArticle> list = q.list();
28792    
28793                    if (list.size() == 2) {
28794                            return list.get(1);
28795                    }
28796                    else {
28797                            return null;
28798                    }
28799            }
28800    
28801            /**
28802             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
28803             *
28804             * @param groupId the group ID
28805             * @param urlTitle the url title
28806             * @param status the status
28807             * @throws SystemException if a system exception occurred
28808             */
28809            @Override
28810            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
28811                    throws SystemException {
28812                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
28813                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
28814                            remove(journalArticle);
28815                    }
28816            }
28817    
28818            /**
28819             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28820             *
28821             * @param groupId the group ID
28822             * @param urlTitle the url title
28823             * @param status the status
28824             * @return the number of matching journal articles
28825             * @throws SystemException if a system exception occurred
28826             */
28827            @Override
28828            public int countByG_UT_ST(long groupId, String urlTitle, int status)
28829                    throws SystemException {
28830                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
28831    
28832                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
28833    
28834                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
28835                                    this);
28836    
28837                    if (count == null) {
28838                            StringBundler query = new StringBundler(4);
28839    
28840                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28841    
28842                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28843    
28844                            boolean bindUrlTitle = false;
28845    
28846                            if (urlTitle == null) {
28847                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28848                            }
28849                            else if (urlTitle.equals(StringPool.BLANK)) {
28850                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28851                            }
28852                            else {
28853                                    bindUrlTitle = true;
28854    
28855                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28856                            }
28857    
28858                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28859    
28860                            String sql = query.toString();
28861    
28862                            Session session = null;
28863    
28864                            try {
28865                                    session = openSession();
28866    
28867                                    Query q = session.createQuery(sql);
28868    
28869                                    QueryPos qPos = QueryPos.getInstance(q);
28870    
28871                                    qPos.add(groupId);
28872    
28873                                    if (bindUrlTitle) {
28874                                            qPos.add(urlTitle);
28875                                    }
28876    
28877                                    qPos.add(status);
28878    
28879                                    count = (Long)q.uniqueResult();
28880    
28881                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28882                            }
28883                            catch (Exception e) {
28884                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28885    
28886                                    throw processException(e);
28887                            }
28888                            finally {
28889                                    closeSession(session);
28890                            }
28891                    }
28892    
28893                    return count.intValue();
28894            }
28895    
28896            /**
28897             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28898             *
28899             * @param groupId the group ID
28900             * @param urlTitle the url title
28901             * @param status the status
28902             * @return the number of matching journal articles that the user has permission to view
28903             * @throws SystemException if a system exception occurred
28904             */
28905            @Override
28906            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
28907                    throws SystemException {
28908                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28909                            return countByG_UT_ST(groupId, urlTitle, status);
28910                    }
28911    
28912                    StringBundler query = new StringBundler(4);
28913    
28914                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
28915    
28916                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28917    
28918                    boolean bindUrlTitle = false;
28919    
28920                    if (urlTitle == null) {
28921                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28922                    }
28923                    else if (urlTitle.equals(StringPool.BLANK)) {
28924                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28925                    }
28926                    else {
28927                            bindUrlTitle = true;
28928    
28929                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28930                    }
28931    
28932                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28933    
28934                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28935                                    JournalArticle.class.getName(),
28936                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28937    
28938                    Session session = null;
28939    
28940                    try {
28941                            session = openSession();
28942    
28943                            SQLQuery q = session.createSQLQuery(sql);
28944    
28945                            q.addScalar(COUNT_COLUMN_NAME,
28946                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
28947    
28948                            QueryPos qPos = QueryPos.getInstance(q);
28949    
28950                            qPos.add(groupId);
28951    
28952                            if (bindUrlTitle) {
28953                                    qPos.add(urlTitle);
28954                            }
28955    
28956                            qPos.add(status);
28957    
28958                            Long count = (Long)q.uniqueResult();
28959    
28960                            return count.intValue();
28961                    }
28962                    catch (Exception e) {
28963                            throw processException(e);
28964                    }
28965                    finally {
28966                            closeSession(session);
28967                    }
28968            }
28969    
28970            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
28971            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
28972            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
28973            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
28974            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
28975            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28976                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28977                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
28978                            "findByC_V_ST",
28979                            new String[] {
28980                                    Long.class.getName(), Double.class.getName(),
28981                                    Integer.class.getName(),
28982                                    
28983                            Integer.class.getName(), Integer.class.getName(),
28984                                    OrderByComparator.class.getName()
28985                            });
28986            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
28987                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28988                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28989                            JournalArticleImpl.class,
28990                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
28991                            new String[] {
28992                                    Long.class.getName(), Double.class.getName(),
28993                                    Integer.class.getName()
28994                            },
28995                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
28996                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
28997                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
28998                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
28999            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29000                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
29001                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
29002                            new String[] {
29003                                    Long.class.getName(), Double.class.getName(),
29004                                    Integer.class.getName()
29005                            });
29006    
29007            /**
29008             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29009             *
29010             * @param companyId the company ID
29011             * @param version the version
29012             * @param status the status
29013             * @return the matching journal articles
29014             * @throws SystemException if a system exception occurred
29015             */
29016            @Override
29017            public List<JournalArticle> findByC_V_ST(long companyId, double version,
29018                    int status) throws SystemException {
29019                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
29020                            QueryUtil.ALL_POS, null);
29021            }
29022    
29023            /**
29024             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29025             *
29026             * <p>
29027             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
29028             * </p>
29029             *
29030             * @param companyId the company ID
29031             * @param version the version
29032             * @param status the status
29033             * @param start the lower bound of the range of journal articles
29034             * @param end the upper bound of the range of journal articles (not inclusive)
29035             * @return the range of matching journal articles
29036             * @throws SystemException if a system exception occurred
29037             */
29038            @Override
29039            public List<JournalArticle> findByC_V_ST(long companyId, double version,
29040                    int status, int start, int end) throws SystemException {
29041                    return findByC_V_ST(companyId, version, status, start, end, null);
29042            }
29043    
29044            /**
29045             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29046             *
29047             * <p>
29048             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
29049             * </p>
29050             *
29051             * @param companyId the company ID
29052             * @param version the version
29053             * @param status the status
29054             * @param start the lower bound of the range of journal articles
29055             * @param end the upper bound of the range of journal articles (not inclusive)
29056             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
29057             * @return the ordered range of matching journal articles
29058             * @throws SystemException if a system exception occurred
29059             */
29060            @Override
29061            public List<JournalArticle> findByC_V_ST(long companyId, double version,
29062                    int status, int start, int end, OrderByComparator orderByComparator)
29063                    throws SystemException {
29064                    boolean pagination = true;
29065                    FinderPath finderPath = null;
29066                    Object[] finderArgs = null;
29067    
29068                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
29069                                    (orderByComparator == null)) {
29070                            pagination = false;
29071                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
29072                            finderArgs = new Object[] { companyId, version, status };
29073                    }
29074                    else {
29075                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
29076                            finderArgs = new Object[] {
29077                                            companyId, version, status,
29078                                            
29079                                            start, end, orderByComparator
29080                                    };
29081                    }
29082    
29083                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
29084                                    finderArgs, this);
29085    
29086                    if ((list != null) && !list.isEmpty()) {
29087                            for (JournalArticle journalArticle : list) {
29088                                    if ((companyId != journalArticle.getCompanyId()) ||
29089                                                    (version != journalArticle.getVersion()) ||
29090                                                    (status != journalArticle.getStatus())) {
29091                                            list = null;
29092    
29093                                            break;
29094                                    }
29095                            }
29096                    }
29097    
29098                    if (list == null) {
29099                            StringBundler query = null;
29100    
29101                            if (orderByComparator != null) {
29102                                    query = new StringBundler(5 +
29103                                                    (orderByComparator.getOrderByFields().length * 3));
29104                            }
29105                            else {
29106                                    query = new StringBundler(5);
29107                            }
29108    
29109                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
29110    
29111                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
29112    
29113                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
29114    
29115                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
29116    
29117                            if (orderByComparator != null) {
29118                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
29119                                            orderByComparator);
29120                            }
29121                            else
29122                             if (pagination) {
29123                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29124                            }
29125    
29126                            String sql = query.toString();
29127    
29128                            Session session = null;
29129    
29130                            try {
29131                                    session = openSession();
29132    
29133                                    Query q = session.createQuery(sql);
29134    
29135                                    QueryPos qPos = QueryPos.getInstance(q);
29136    
29137                                    qPos.add(companyId);
29138    
29139                                    qPos.add(version);
29140    
29141                                    qPos.add(status);
29142    
29143                                    if (!pagination) {
29144                                            list = (List<JournalArticle>)QueryUtil.list(q,
29145                                                            getDialect(), start, end, false);
29146    
29147                                            Collections.sort(list);
29148    
29149                                            list = new UnmodifiableList<JournalArticle>(list);
29150                                    }
29151                                    else {
29152                                            list = (List<JournalArticle>)QueryUtil.list(q,
29153                                                            getDialect(), start, end);
29154                                    }
29155    
29156                                    cacheResult(list);
29157    
29158                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
29159                            }
29160                            catch (Exception e) {
29161                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
29162    
29163                                    throw processException(e);
29164                            }
29165                            finally {
29166                                    closeSession(session);
29167                            }
29168                    }
29169    
29170                    return list;
29171            }
29172    
29173            /**
29174             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29175             *
29176             * @param companyId the company ID
29177             * @param version the version
29178             * @param status the status
29179             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29180             * @return the first matching journal article
29181             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
29182             * @throws SystemException if a system exception occurred
29183             */
29184            @Override
29185            public JournalArticle findByC_V_ST_First(long companyId, double version,
29186                    int status, OrderByComparator orderByComparator)
29187                    throws NoSuchArticleException, SystemException {
29188                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
29189                                    status, orderByComparator);
29190    
29191                    if (journalArticle != null) {
29192                            return journalArticle;
29193                    }
29194    
29195                    StringBundler msg = new StringBundler(8);
29196    
29197                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
29198    
29199                    msg.append("companyId=");
29200                    msg.append(companyId);
29201    
29202                    msg.append(", version=");
29203                    msg.append(version);
29204    
29205                    msg.append(", status=");
29206                    msg.append(status);
29207    
29208                    msg.append(StringPool.CLOSE_CURLY_BRACE);
29209    
29210                    throw new NoSuchArticleException(msg.toString());
29211            }
29212    
29213            /**
29214             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29215             *
29216             * @param companyId the company ID
29217             * @param version the version
29218             * @param status the status
29219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29220             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
29221             * @throws SystemException if a system exception occurred
29222             */
29223            @Override
29224            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
29225                    int status, OrderByComparator orderByComparator)
29226                    throws SystemException {
29227                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
29228                                    1, orderByComparator);
29229    
29230                    if (!list.isEmpty()) {
29231                            return list.get(0);
29232                    }
29233    
29234                    return null;
29235            }
29236    
29237            /**
29238             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29239             *
29240             * @param companyId the company ID
29241             * @param version the version
29242             * @param status the status
29243             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29244             * @return the last matching journal article
29245             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
29246             * @throws SystemException if a system exception occurred
29247             */
29248            @Override
29249            public JournalArticle findByC_V_ST_Last(long companyId, double version,
29250                    int status, OrderByComparator orderByComparator)
29251                    throws NoSuchArticleException, SystemException {
29252                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
29253                                    status, orderByComparator);
29254    
29255                    if (journalArticle != null) {
29256                            return journalArticle;
29257                    }
29258    
29259                    StringBundler msg = new StringBundler(8);
29260    
29261                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
29262    
29263                    msg.append("companyId=");
29264                    msg.append(companyId);
29265    
29266                    msg.append(", version=");
29267                    msg.append(version);
29268    
29269                    msg.append(", status=");
29270                    msg.append(status);
29271    
29272                    msg.append(StringPool.CLOSE_CURLY_BRACE);
29273    
29274                    throw new NoSuchArticleException(msg.toString());
29275            }
29276    
29277            /**
29278             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29279             *
29280             * @param companyId the company ID
29281             * @param version the version
29282             * @param status the status
29283             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29284             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
29285             * @throws SystemException if a system exception occurred
29286             */
29287            @Override
29288            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
29289                    int status, OrderByComparator orderByComparator)
29290                    throws SystemException {
29291                    int count = countByC_V_ST(companyId, version, status);
29292    
29293                    if (count == 0) {
29294                            return null;
29295                    }
29296    
29297                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
29298                                    count - 1, count, orderByComparator);
29299    
29300                    if (!list.isEmpty()) {
29301                            return list.get(0);
29302                    }
29303    
29304                    return null;
29305            }
29306    
29307            /**
29308             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29309             *
29310             * @param id the primary key of the current journal article
29311             * @param companyId the company ID
29312             * @param version the version
29313             * @param status the status
29314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29315             * @return the previous, current, and next journal article
29316             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29317             * @throws SystemException if a system exception occurred
29318             */
29319            @Override
29320            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
29321                    double version, int status, OrderByComparator orderByComparator)
29322                    throws NoSuchArticleException, SystemException {
29323                    JournalArticle journalArticle = findByPrimaryKey(id);
29324    
29325                    Session session = null;
29326    
29327                    try {
29328                            session = openSession();
29329    
29330                            JournalArticle[] array = new JournalArticleImpl[3];
29331    
29332                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
29333                                            companyId, version, status, orderByComparator, true);
29334    
29335                            array[1] = journalArticle;
29336    
29337                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
29338                                            companyId, version, status, orderByComparator, false);
29339    
29340                            return array;
29341                    }
29342                    catch (Exception e) {
29343                            throw processException(e);
29344                    }
29345                    finally {
29346                            closeSession(session);
29347                    }
29348            }
29349    
29350            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
29351                    JournalArticle journalArticle, long companyId, double version,
29352                    int status, OrderByComparator orderByComparator, boolean previous) {
29353                    StringBundler query = null;
29354    
29355                    if (orderByComparator != null) {
29356                            query = new StringBundler(6 +
29357                                            (orderByComparator.getOrderByFields().length * 6));
29358                    }
29359                    else {
29360                            query = new StringBundler(3);
29361                    }
29362    
29363                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
29364    
29365                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
29366    
29367                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
29368    
29369                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
29370    
29371                    if (orderByComparator != null) {
29372                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
29373    
29374                            if (orderByConditionFields.length > 0) {
29375                                    query.append(WHERE_AND);
29376                            }
29377    
29378                            for (int i = 0; i < orderByConditionFields.length; i++) {
29379                                    query.append(_ORDER_BY_ENTITY_ALIAS);
29380                                    query.append(orderByConditionFields[i]);
29381    
29382                                    if ((i + 1) < orderByConditionFields.length) {
29383                                            if (orderByComparator.isAscending() ^ previous) {
29384                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
29385                                            }
29386                                            else {
29387                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
29388                                            }
29389                                    }
29390                                    else {
29391                                            if (orderByComparator.isAscending() ^ previous) {
29392                                                    query.append(WHERE_GREATER_THAN);
29393                                            }
29394                                            else {
29395                                                    query.append(WHERE_LESSER_THAN);
29396                                            }
29397                                    }
29398                            }
29399    
29400                            query.append(ORDER_BY_CLAUSE);
29401    
29402                            String[] orderByFields = orderByComparator.getOrderByFields();
29403    
29404                            for (int i = 0; i < orderByFields.length; i++) {
29405                                    query.append(_ORDER_BY_ENTITY_ALIAS);
29406                                    query.append(orderByFields[i]);
29407    
29408                                    if ((i + 1) < orderByFields.length) {
29409                                            if (orderByComparator.isAscending() ^ previous) {
29410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
29411                                            }
29412                                            else {
29413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
29414                                            }
29415                                    }
29416                                    else {
29417                                            if (orderByComparator.isAscending() ^ previous) {
29418                                                    query.append(ORDER_BY_ASC);
29419                                            }
29420                                            else {
29421                                                    query.append(ORDER_BY_DESC);
29422                                            }
29423                                    }
29424                            }
29425                    }
29426                    else {
29427                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29428                    }
29429    
29430                    String sql = query.toString();
29431    
29432                    Query q = session.createQuery(sql);
29433    
29434                    q.setFirstResult(0);
29435                    q.setMaxResults(2);
29436    
29437                    QueryPos qPos = QueryPos.getInstance(q);
29438    
29439                    qPos.add(companyId);
29440    
29441                    qPos.add(version);
29442    
29443                    qPos.add(status);
29444    
29445                    if (orderByComparator != null) {
29446                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
29447    
29448                            for (Object value : values) {
29449                                    qPos.add(value);
29450                            }
29451                    }
29452    
29453                    List<JournalArticle> list = q.list();
29454    
29455                    if (list.size() == 2) {
29456                            return list.get(1);
29457                    }
29458                    else {
29459                            return null;
29460                    }
29461            }
29462    
29463            /**
29464             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
29465             *
29466             * @param companyId the company ID
29467             * @param version the version
29468             * @param status the status
29469             * @throws SystemException if a system exception occurred
29470             */
29471            @Override
29472            public void removeByC_V_ST(long companyId, double version, int status)
29473                    throws SystemException {
29474                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
29475                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
29476                            remove(journalArticle);
29477                    }
29478            }
29479    
29480            /**
29481             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29482             *
29483             * @param companyId the company ID
29484             * @param version the version
29485             * @param status the status
29486             * @return the number of matching journal articles
29487             * @throws SystemException if a system exception occurred
29488             */
29489            @Override
29490            public int countByC_V_ST(long companyId, double version, int status)
29491                    throws SystemException {
29492                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
29493    
29494                    Object[] finderArgs = new Object[] { companyId, version, status };
29495    
29496                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
29497                                    this);
29498    
29499                    if (count == null) {
29500                            StringBundler query = new StringBundler(4);
29501    
29502                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
29503    
29504                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
29505    
29506                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
29507    
29508                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
29509    
29510                            String sql = query.toString();
29511    
29512                            Session session = null;
29513    
29514                            try {
29515                                    session = openSession();
29516    
29517                                    Query q = session.createQuery(sql);
29518    
29519                                    QueryPos qPos = QueryPos.getInstance(q);
29520    
29521                                    qPos.add(companyId);
29522    
29523                                    qPos.add(version);
29524    
29525                                    qPos.add(status);
29526    
29527                                    count = (Long)q.uniqueResult();
29528    
29529                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
29530                            }
29531                            catch (Exception e) {
29532                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
29533    
29534                                    throw processException(e);
29535                            }
29536                            finally {
29537                                    closeSession(session);
29538                            }
29539                    }
29540    
29541                    return count.intValue();
29542            }
29543    
29544            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
29545            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
29546            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
29547    
29548            public JournalArticlePersistenceImpl() {
29549                    setModelClass(JournalArticle.class);
29550            }
29551    
29552            /**
29553             * Caches the journal article in the entity cache if it is enabled.
29554             *
29555             * @param journalArticle the journal article
29556             */
29557            @Override
29558            public void cacheResult(JournalArticle journalArticle) {
29559                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29560                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
29561                            journalArticle);
29562    
29563                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
29564                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
29565                            journalArticle);
29566    
29567                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
29568                            new Object[] {
29569                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
29570                                    journalArticle.getStructureId()
29571                            }, journalArticle);
29572    
29573                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
29574                            new Object[] {
29575                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
29576                                    journalArticle.getVersion()
29577                            }, journalArticle);
29578    
29579                    journalArticle.resetOriginalValues();
29580            }
29581    
29582            /**
29583             * Caches the journal articles in the entity cache if it is enabled.
29584             *
29585             * @param journalArticles the journal articles
29586             */
29587            @Override
29588            public void cacheResult(List<JournalArticle> journalArticles) {
29589                    for (JournalArticle journalArticle : journalArticles) {
29590                            if (EntityCacheUtil.getResult(
29591                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29592                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
29593                                    cacheResult(journalArticle);
29594                            }
29595                            else {
29596                                    journalArticle.resetOriginalValues();
29597                            }
29598                    }
29599            }
29600    
29601            /**
29602             * Clears the cache for all journal articles.
29603             *
29604             * <p>
29605             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
29606             * </p>
29607             */
29608            @Override
29609            public void clearCache() {
29610                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
29611                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
29612                    }
29613    
29614                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
29615    
29616                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
29617                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29618                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29619            }
29620    
29621            /**
29622             * Clears the cache for the journal article.
29623             *
29624             * <p>
29625             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
29626             * </p>
29627             */
29628            @Override
29629            public void clearCache(JournalArticle journalArticle) {
29630                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29631                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
29632    
29633                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29634                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29635    
29636                    clearUniqueFindersCache(journalArticle);
29637            }
29638    
29639            @Override
29640            public void clearCache(List<JournalArticle> journalArticles) {
29641                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29642                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29643    
29644                    for (JournalArticle journalArticle : journalArticles) {
29645                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29646                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
29647    
29648                            clearUniqueFindersCache(journalArticle);
29649                    }
29650            }
29651    
29652            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
29653                    if (journalArticle.isNew()) {
29654                            Object[] args = new Object[] {
29655                                            journalArticle.getUuid(), journalArticle.getGroupId()
29656                                    };
29657    
29658                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
29659                                    Long.valueOf(1));
29660                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
29661                                    journalArticle);
29662    
29663                            args = new Object[] {
29664                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
29665                                            journalArticle.getStructureId()
29666                                    };
29667    
29668                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
29669                                    Long.valueOf(1));
29670                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
29671                                    journalArticle);
29672    
29673                            args = new Object[] {
29674                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
29675                                            journalArticle.getVersion()
29676                                    };
29677    
29678                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
29679                                    Long.valueOf(1));
29680                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
29681                                    journalArticle);
29682                    }
29683                    else {
29684                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29685    
29686                            if ((journalArticleModelImpl.getColumnBitmask() &
29687                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
29688                                    Object[] args = new Object[] {
29689                                                    journalArticle.getUuid(), journalArticle.getGroupId()
29690                                            };
29691    
29692                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
29693                                            Long.valueOf(1));
29694                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
29695                                            journalArticle);
29696                            }
29697    
29698                            if ((journalArticleModelImpl.getColumnBitmask() &
29699                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
29700                                    Object[] args = new Object[] {
29701                                                    journalArticle.getGroupId(),
29702                                                    journalArticle.getClassNameId(),
29703                                                    journalArticle.getStructureId()
29704                                            };
29705    
29706                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
29707                                            Long.valueOf(1));
29708                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
29709                                            journalArticle);
29710                            }
29711    
29712                            if ((journalArticleModelImpl.getColumnBitmask() &
29713                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
29714                                    Object[] args = new Object[] {
29715                                                    journalArticle.getGroupId(),
29716                                                    journalArticle.getArticleId(),
29717                                                    journalArticle.getVersion()
29718                                            };
29719    
29720                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
29721                                            Long.valueOf(1));
29722                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
29723                                            journalArticle);
29724                            }
29725                    }
29726            }
29727    
29728            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
29729                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29730    
29731                    Object[] args = new Object[] {
29732                                    journalArticle.getUuid(), journalArticle.getGroupId()
29733                            };
29734    
29735                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
29736                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
29737    
29738                    if ((journalArticleModelImpl.getColumnBitmask() &
29739                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
29740                            args = new Object[] {
29741                                            journalArticleModelImpl.getOriginalUuid(),
29742                                            journalArticleModelImpl.getOriginalGroupId()
29743                                    };
29744    
29745                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
29746                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
29747                    }
29748    
29749                    args = new Object[] {
29750                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
29751                                    journalArticle.getStructureId()
29752                            };
29753    
29754                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
29755                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
29756    
29757                    if ((journalArticleModelImpl.getColumnBitmask() &
29758                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
29759                            args = new Object[] {
29760                                            journalArticleModelImpl.getOriginalGroupId(),
29761                                            journalArticleModelImpl.getOriginalClassNameId(),
29762                                            journalArticleModelImpl.getOriginalStructureId()
29763                                    };
29764    
29765                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
29766                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
29767                    }
29768    
29769                    args = new Object[] {
29770                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
29771                                    journalArticle.getVersion()
29772                            };
29773    
29774                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
29775                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
29776    
29777                    if ((journalArticleModelImpl.getColumnBitmask() &
29778                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
29779                            args = new Object[] {
29780                                            journalArticleModelImpl.getOriginalGroupId(),
29781                                            journalArticleModelImpl.getOriginalArticleId(),
29782                                            journalArticleModelImpl.getOriginalVersion()
29783                                    };
29784    
29785                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
29786                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
29787                    }
29788            }
29789    
29790            /**
29791             * Creates a new journal article with the primary key. Does not add the journal article to the database.
29792             *
29793             * @param id the primary key for the new journal article
29794             * @return the new journal article
29795             */
29796            @Override
29797            public JournalArticle create(long id) {
29798                    JournalArticle journalArticle = new JournalArticleImpl();
29799    
29800                    journalArticle.setNew(true);
29801                    journalArticle.setPrimaryKey(id);
29802    
29803                    String uuid = PortalUUIDUtil.generate();
29804    
29805                    journalArticle.setUuid(uuid);
29806    
29807                    return journalArticle;
29808            }
29809    
29810            /**
29811             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
29812             *
29813             * @param id the primary key of the journal article
29814             * @return the journal article that was removed
29815             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29816             * @throws SystemException if a system exception occurred
29817             */
29818            @Override
29819            public JournalArticle remove(long id)
29820                    throws NoSuchArticleException, SystemException {
29821                    return remove((Serializable)id);
29822            }
29823    
29824            /**
29825             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
29826             *
29827             * @param primaryKey the primary key of the journal article
29828             * @return the journal article that was removed
29829             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29830             * @throws SystemException if a system exception occurred
29831             */
29832            @Override
29833            public JournalArticle remove(Serializable primaryKey)
29834                    throws NoSuchArticleException, SystemException {
29835                    Session session = null;
29836    
29837                    try {
29838                            session = openSession();
29839    
29840                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29841                                            primaryKey);
29842    
29843                            if (journalArticle == null) {
29844                                    if (_log.isWarnEnabled()) {
29845                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
29846                                    }
29847    
29848                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
29849                                            primaryKey);
29850                            }
29851    
29852                            return remove(journalArticle);
29853                    }
29854                    catch (NoSuchArticleException nsee) {
29855                            throw nsee;
29856                    }
29857                    catch (Exception e) {
29858                            throw processException(e);
29859                    }
29860                    finally {
29861                            closeSession(session);
29862                    }
29863            }
29864    
29865            @Override
29866            protected JournalArticle removeImpl(JournalArticle journalArticle)
29867                    throws SystemException {
29868                    journalArticle = toUnwrappedModel(journalArticle);
29869    
29870                    Session session = null;
29871    
29872                    try {
29873                            session = openSession();
29874    
29875                            if (!session.contains(journalArticle)) {
29876                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29877                                                    journalArticle.getPrimaryKeyObj());
29878                            }
29879    
29880                            if (journalArticle != null) {
29881                                    session.delete(journalArticle);
29882                            }
29883                    }
29884                    catch (Exception e) {
29885                            throw processException(e);
29886                    }
29887                    finally {
29888                            closeSession(session);
29889                    }
29890    
29891                    if (journalArticle != null) {
29892                            clearCache(journalArticle);
29893                    }
29894    
29895                    return journalArticle;
29896            }
29897    
29898            @Override
29899            public JournalArticle updateImpl(
29900                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
29901                    throws SystemException {
29902                    journalArticle = toUnwrappedModel(journalArticle);
29903    
29904                    boolean isNew = journalArticle.isNew();
29905    
29906                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29907    
29908                    if (Validator.isNull(journalArticle.getUuid())) {
29909                            String uuid = PortalUUIDUtil.generate();
29910    
29911                            journalArticle.setUuid(uuid);
29912                    }
29913    
29914                    Session session = null;
29915    
29916                    try {
29917                            session = openSession();
29918    
29919                            if (journalArticle.isNew()) {
29920                                    session.save(journalArticle);
29921    
29922                                    journalArticle.setNew(false);
29923                            }
29924                            else {
29925                                    session.merge(journalArticle);
29926                            }
29927                    }
29928                    catch (Exception e) {
29929                            throw processException(e);
29930                    }
29931                    finally {
29932                            closeSession(session);
29933                    }
29934    
29935                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29936    
29937                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
29938                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29939                    }
29940    
29941                    else {
29942                            if ((journalArticleModelImpl.getColumnBitmask() &
29943                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
29944                                    Object[] args = new Object[] {
29945                                                    journalArticleModelImpl.getOriginalUuid()
29946                                            };
29947    
29948                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29949                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29950                                            args);
29951    
29952                                    args = new Object[] { journalArticleModelImpl.getUuid() };
29953    
29954                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29955                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29956                                            args);
29957                            }
29958    
29959                            if ((journalArticleModelImpl.getColumnBitmask() &
29960                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
29961                                    Object[] args = new Object[] {
29962                                                    journalArticleModelImpl.getOriginalUuid(),
29963                                                    journalArticleModelImpl.getOriginalCompanyId()
29964                                            };
29965    
29966                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29967                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29968                                            args);
29969    
29970                                    args = new Object[] {
29971                                                    journalArticleModelImpl.getUuid(),
29972                                                    journalArticleModelImpl.getCompanyId()
29973                                            };
29974    
29975                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29976                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29977                                            args);
29978                            }
29979    
29980                            if ((journalArticleModelImpl.getColumnBitmask() &
29981                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
29982                                    Object[] args = new Object[] {
29983                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
29984                                            };
29985    
29986                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29987                                            args);
29988                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29989                                            args);
29990    
29991                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
29992    
29993                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29994                                            args);
29995                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29996                                            args);
29997                            }
29998    
29999                            if ((journalArticleModelImpl.getColumnBitmask() &
30000                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
30001                                    Object[] args = new Object[] {
30002                                                    journalArticleModelImpl.getOriginalGroupId()
30003                                            };
30004    
30005                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
30006                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
30007                                            args);
30008    
30009                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
30010    
30011                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
30012                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
30013                                            args);
30014                            }
30015    
30016                            if ((journalArticleModelImpl.getColumnBitmask() &
30017                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
30018                                    Object[] args = new Object[] {
30019                                                    journalArticleModelImpl.getOriginalCompanyId()
30020                                            };
30021    
30022                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
30023                                            args);
30024                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
30025                                            args);
30026    
30027                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
30028    
30029                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
30030                                            args);
30031                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
30032                                            args);
30033                            }
30034    
30035                            if ((journalArticleModelImpl.getColumnBitmask() &
30036                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
30037                                    Object[] args = new Object[] {
30038                                                    journalArticleModelImpl.getOriginalStructureId()
30039                                            };
30040    
30041                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
30042                                            args);
30043                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
30044                                            args);
30045    
30046                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
30047    
30048                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
30049                                            args);
30050                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
30051                                            args);
30052                            }
30053    
30054                            if ((journalArticleModelImpl.getColumnBitmask() &
30055                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
30056                                    Object[] args = new Object[] {
30057                                                    journalArticleModelImpl.getOriginalTemplateId()
30058                                            };
30059    
30060                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
30061                                            args);
30062                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
30063                                            args);
30064    
30065                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
30066    
30067                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
30068                                            args);
30069                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
30070                                            args);
30071                            }
30072    
30073                            if ((journalArticleModelImpl.getColumnBitmask() &
30074                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
30075                                    Object[] args = new Object[] {
30076                                                    journalArticleModelImpl.getOriginalLayoutUuid()
30077                                            };
30078    
30079                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
30080                                            args);
30081                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
30082                                            args);
30083    
30084                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
30085    
30086                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
30087                                            args);
30088                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
30089                                            args);
30090                            }
30091    
30092                            if ((journalArticleModelImpl.getColumnBitmask() &
30093                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
30094                                    Object[] args = new Object[] {
30095                                                    journalArticleModelImpl.getOriginalSmallImageId()
30096                                            };
30097    
30098                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
30099                                            args);
30100                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
30101                                            args);
30102    
30103                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
30104    
30105                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
30106                                            args);
30107                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
30108                                            args);
30109                            }
30110    
30111                            if ((journalArticleModelImpl.getColumnBitmask() &
30112                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I.getColumnBitmask()) != 0) {
30113                                    Object[] args = new Object[] {
30114                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
30115                                                    journalArticleModelImpl.getOriginalIndexable()
30116                                            };
30117    
30118                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
30119                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
30120                                            args);
30121    
30122                                    args = new Object[] {
30123                                                    journalArticleModelImpl.getResourcePrimKey(),
30124                                                    journalArticleModelImpl.getIndexable()
30125                                            };
30126    
30127                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
30128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
30129                                            args);
30130                            }
30131    
30132                            if ((journalArticleModelImpl.getColumnBitmask() &
30133                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
30134                                    Object[] args = new Object[] {
30135                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
30136                                                    journalArticleModelImpl.getOriginalStatus()
30137                                            };
30138    
30139                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
30140                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
30141                                            args);
30142    
30143                                    args = new Object[] {
30144                                                    journalArticleModelImpl.getResourcePrimKey(),
30145                                                    journalArticleModelImpl.getStatus()
30146                                            };
30147    
30148                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
30149                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
30150                                            args);
30151                            }
30152    
30153                            if ((journalArticleModelImpl.getColumnBitmask() &
30154                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
30155                                    Object[] args = new Object[] {
30156                                                    journalArticleModelImpl.getOriginalGroupId(),
30157                                                    journalArticleModelImpl.getOriginalUserId()
30158                                            };
30159    
30160                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
30161                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
30162                                            args);
30163    
30164                                    args = new Object[] {
30165                                                    journalArticleModelImpl.getGroupId(),
30166                                                    journalArticleModelImpl.getUserId()
30167                                            };
30168    
30169                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
30170                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
30171                                            args);
30172                            }
30173    
30174                            if ((journalArticleModelImpl.getColumnBitmask() &
30175                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
30176                                    Object[] args = new Object[] {
30177                                                    journalArticleModelImpl.getOriginalGroupId(),
30178                                                    journalArticleModelImpl.getOriginalFolderId()
30179                                            };
30180    
30181                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
30182                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
30183                                            args);
30184    
30185                                    args = new Object[] {
30186                                                    journalArticleModelImpl.getGroupId(),
30187                                                    journalArticleModelImpl.getFolderId()
30188                                            };
30189    
30190                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
30191                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
30192                                            args);
30193                            }
30194    
30195                            if ((journalArticleModelImpl.getColumnBitmask() &
30196                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
30197                                    Object[] args = new Object[] {
30198                                                    journalArticleModelImpl.getOriginalGroupId(),
30199                                                    journalArticleModelImpl.getOriginalArticleId()
30200                                            };
30201    
30202                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
30203                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
30204                                            args);
30205    
30206                                    args = new Object[] {
30207                                                    journalArticleModelImpl.getGroupId(),
30208                                                    journalArticleModelImpl.getArticleId()
30209                                            };
30210    
30211                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
30212                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
30213                                            args);
30214                            }
30215    
30216                            if ((journalArticleModelImpl.getColumnBitmask() &
30217                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
30218                                    Object[] args = new Object[] {
30219                                                    journalArticleModelImpl.getOriginalGroupId(),
30220                                                    journalArticleModelImpl.getOriginalUrlTitle()
30221                                            };
30222    
30223                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
30224                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
30225                                            args);
30226    
30227                                    args = new Object[] {
30228                                                    journalArticleModelImpl.getGroupId(),
30229                                                    journalArticleModelImpl.getUrlTitle()
30230                                            };
30231    
30232                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
30233                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
30234                                            args);
30235                            }
30236    
30237                            if ((journalArticleModelImpl.getColumnBitmask() &
30238                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
30239                                    Object[] args = new Object[] {
30240                                                    journalArticleModelImpl.getOriginalGroupId(),
30241                                                    journalArticleModelImpl.getOriginalStructureId()
30242                                            };
30243    
30244                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
30245                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
30246                                            args);
30247    
30248                                    args = new Object[] {
30249                                                    journalArticleModelImpl.getGroupId(),
30250                                                    journalArticleModelImpl.getStructureId()
30251                                            };
30252    
30253                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
30254                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
30255                                            args);
30256                            }
30257    
30258                            if ((journalArticleModelImpl.getColumnBitmask() &
30259                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
30260                                    Object[] args = new Object[] {
30261                                                    journalArticleModelImpl.getOriginalGroupId(),
30262                                                    journalArticleModelImpl.getOriginalTemplateId()
30263                                            };
30264    
30265                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
30266                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
30267                                            args);
30268    
30269                                    args = new Object[] {
30270                                                    journalArticleModelImpl.getGroupId(),
30271                                                    journalArticleModelImpl.getTemplateId()
30272                                            };
30273    
30274                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
30275                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
30276                                            args);
30277                            }
30278    
30279                            if ((journalArticleModelImpl.getColumnBitmask() &
30280                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
30281                                    Object[] args = new Object[] {
30282                                                    journalArticleModelImpl.getOriginalGroupId(),
30283                                                    journalArticleModelImpl.getOriginalLayoutUuid()
30284                                            };
30285    
30286                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
30287                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
30288                                            args);
30289    
30290                                    args = new Object[] {
30291                                                    journalArticleModelImpl.getGroupId(),
30292                                                    journalArticleModelImpl.getLayoutUuid()
30293                                            };
30294    
30295                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
30296                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
30297                                            args);
30298                            }
30299    
30300                            if ((journalArticleModelImpl.getColumnBitmask() &
30301                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
30302                                    Object[] args = new Object[] {
30303                                                    journalArticleModelImpl.getOriginalGroupId(),
30304                                                    journalArticleModelImpl.getOriginalStatus()
30305                                            };
30306    
30307                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
30308                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
30309                                            args);
30310    
30311                                    args = new Object[] {
30312                                                    journalArticleModelImpl.getGroupId(),
30313                                                    journalArticleModelImpl.getStatus()
30314                                            };
30315    
30316                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
30317                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
30318                                            args);
30319                            }
30320    
30321                            if ((journalArticleModelImpl.getColumnBitmask() &
30322                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
30323                                    Object[] args = new Object[] {
30324                                                    journalArticleModelImpl.getOriginalCompanyId(),
30325                                                    journalArticleModelImpl.getOriginalVersion()
30326                                            };
30327    
30328                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
30329                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
30330                                            args);
30331    
30332                                    args = new Object[] {
30333                                                    journalArticleModelImpl.getCompanyId(),
30334                                                    journalArticleModelImpl.getVersion()
30335                                            };
30336    
30337                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
30338                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
30339                                            args);
30340                            }
30341    
30342                            if ((journalArticleModelImpl.getColumnBitmask() &
30343                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
30344                                    Object[] args = new Object[] {
30345                                                    journalArticleModelImpl.getOriginalCompanyId(),
30346                                                    journalArticleModelImpl.getOriginalStatus()
30347                                            };
30348    
30349                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
30350                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
30351                                            args);
30352    
30353                                    args = new Object[] {
30354                                                    journalArticleModelImpl.getCompanyId(),
30355                                                    journalArticleModelImpl.getStatus()
30356                                            };
30357    
30358                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
30359                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
30360                                            args);
30361                            }
30362    
30363                            if ((journalArticleModelImpl.getColumnBitmask() &
30364                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T.getColumnBitmask()) != 0) {
30365                                    Object[] args = new Object[] {
30366                                                    journalArticleModelImpl.getOriginalClassNameId(),
30367                                                    journalArticleModelImpl.getOriginalTemplateId()
30368                                            };
30369    
30370                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
30371                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
30372                                            args);
30373    
30374                                    args = new Object[] {
30375                                                    journalArticleModelImpl.getClassNameId(),
30376                                                    journalArticleModelImpl.getTemplateId()
30377                                            };
30378    
30379                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
30380                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
30381                                            args);
30382                            }
30383    
30384                            if ((journalArticleModelImpl.getColumnBitmask() &
30385                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
30386                                    Object[] args = new Object[] {
30387                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
30388                                                    journalArticleModelImpl.getOriginalIndexable(),
30389                                                    journalArticleModelImpl.getOriginalStatus()
30390                                            };
30391    
30392                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
30393                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
30394                                            args);
30395    
30396                                    args = new Object[] {
30397                                                    journalArticleModelImpl.getResourcePrimKey(),
30398                                                    journalArticleModelImpl.getIndexable(),
30399                                                    journalArticleModelImpl.getStatus()
30400                                            };
30401    
30402                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
30403                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
30404                                            args);
30405                            }
30406    
30407                            if ((journalArticleModelImpl.getColumnBitmask() &
30408                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
30409                                    Object[] args = new Object[] {
30410                                                    journalArticleModelImpl.getOriginalGroupId(),
30411                                                    journalArticleModelImpl.getOriginalUserId(),
30412                                                    journalArticleModelImpl.getOriginalClassNameId()
30413                                            };
30414    
30415                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
30416                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
30417                                            args);
30418    
30419                                    args = new Object[] {
30420                                                    journalArticleModelImpl.getGroupId(),
30421                                                    journalArticleModelImpl.getUserId(),
30422                                                    journalArticleModelImpl.getClassNameId()
30423                                            };
30424    
30425                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
30426                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
30427                                            args);
30428                            }
30429    
30430                            if ((journalArticleModelImpl.getColumnBitmask() &
30431                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
30432                                    Object[] args = new Object[] {
30433                                                    journalArticleModelImpl.getOriginalGroupId(),
30434                                                    journalArticleModelImpl.getOriginalFolderId(),
30435                                                    journalArticleModelImpl.getOriginalStatus()
30436                                            };
30437    
30438                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
30439                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
30440                                            args);
30441    
30442                                    args = new Object[] {
30443                                                    journalArticleModelImpl.getGroupId(),
30444                                                    journalArticleModelImpl.getFolderId(),
30445                                                    journalArticleModelImpl.getStatus()
30446                                            };
30447    
30448                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
30449                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
30450                                            args);
30451                            }
30452    
30453                            if ((journalArticleModelImpl.getColumnBitmask() &
30454                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
30455                                    Object[] args = new Object[] {
30456                                                    journalArticleModelImpl.getOriginalGroupId(),
30457                                                    journalArticleModelImpl.getOriginalClassNameId(),
30458                                                    journalArticleModelImpl.getOriginalClassPK()
30459                                            };
30460    
30461                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
30462                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
30463                                            args);
30464    
30465                                    args = new Object[] {
30466                                                    journalArticleModelImpl.getGroupId(),
30467                                                    journalArticleModelImpl.getClassNameId(),
30468                                                    journalArticleModelImpl.getClassPK()
30469                                            };
30470    
30471                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
30472                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
30473                                            args);
30474                            }
30475    
30476                            if ((journalArticleModelImpl.getColumnBitmask() &
30477                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
30478                                    Object[] args = new Object[] {
30479                                                    journalArticleModelImpl.getOriginalGroupId(),
30480                                                    journalArticleModelImpl.getOriginalClassNameId(),
30481                                                    journalArticleModelImpl.getOriginalTemplateId()
30482                                            };
30483    
30484                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
30485                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
30486                                            args);
30487    
30488                                    args = new Object[] {
30489                                                    journalArticleModelImpl.getGroupId(),
30490                                                    journalArticleModelImpl.getClassNameId(),
30491                                                    journalArticleModelImpl.getTemplateId()
30492                                            };
30493    
30494                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
30495                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
30496                                            args);
30497                            }
30498    
30499                            if ((journalArticleModelImpl.getColumnBitmask() &
30500                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
30501                                    Object[] args = new Object[] {
30502                                                    journalArticleModelImpl.getOriginalGroupId(),
30503                                                    journalArticleModelImpl.getOriginalClassNameId(),
30504                                                    journalArticleModelImpl.getOriginalLayoutUuid()
30505                                            };
30506    
30507                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
30508                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
30509                                            args);
30510    
30511                                    args = new Object[] {
30512                                                    journalArticleModelImpl.getGroupId(),
30513                                                    journalArticleModelImpl.getClassNameId(),
30514                                                    journalArticleModelImpl.getLayoutUuid()
30515                                            };
30516    
30517                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
30518                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
30519                                            args);
30520                            }
30521    
30522                            if ((journalArticleModelImpl.getColumnBitmask() &
30523                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
30524                                    Object[] args = new Object[] {
30525                                                    journalArticleModelImpl.getOriginalGroupId(),
30526                                                    journalArticleModelImpl.getOriginalArticleId(),
30527                                                    journalArticleModelImpl.getOriginalStatus()
30528                                            };
30529    
30530                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
30531                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
30532                                            args);
30533    
30534                                    args = new Object[] {
30535                                                    journalArticleModelImpl.getGroupId(),
30536                                                    journalArticleModelImpl.getArticleId(),
30537                                                    journalArticleModelImpl.getStatus()
30538                                            };
30539    
30540                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
30541                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
30542                                            args);
30543                            }
30544    
30545                            if ((journalArticleModelImpl.getColumnBitmask() &
30546                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
30547                                    Object[] args = new Object[] {
30548                                                    journalArticleModelImpl.getOriginalGroupId(),
30549                                                    journalArticleModelImpl.getOriginalUrlTitle(),
30550                                                    journalArticleModelImpl.getOriginalStatus()
30551                                            };
30552    
30553                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
30554                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
30555                                            args);
30556    
30557                                    args = new Object[] {
30558                                                    journalArticleModelImpl.getGroupId(),
30559                                                    journalArticleModelImpl.getUrlTitle(),
30560                                                    journalArticleModelImpl.getStatus()
30561                                            };
30562    
30563                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
30564                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
30565                                            args);
30566                            }
30567    
30568                            if ((journalArticleModelImpl.getColumnBitmask() &
30569                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
30570                                    Object[] args = new Object[] {
30571                                                    journalArticleModelImpl.getOriginalCompanyId(),
30572                                                    journalArticleModelImpl.getOriginalVersion(),
30573                                                    journalArticleModelImpl.getOriginalStatus()
30574                                            };
30575    
30576                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
30577                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
30578                                            args);
30579    
30580                                    args = new Object[] {
30581                                                    journalArticleModelImpl.getCompanyId(),
30582                                                    journalArticleModelImpl.getVersion(),
30583                                                    journalArticleModelImpl.getStatus()
30584                                            };
30585    
30586                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
30587                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
30588                                            args);
30589                            }
30590                    }
30591    
30592                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30593                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
30594                            journalArticle);
30595    
30596                    clearUniqueFindersCache(journalArticle);
30597                    cacheUniqueFindersCache(journalArticle);
30598    
30599                    return journalArticle;
30600            }
30601    
30602            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
30603                    if (journalArticle instanceof JournalArticleImpl) {
30604                            return journalArticle;
30605                    }
30606    
30607                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
30608    
30609                    journalArticleImpl.setNew(journalArticle.isNew());
30610                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
30611    
30612                    journalArticleImpl.setUuid(journalArticle.getUuid());
30613                    journalArticleImpl.setId(journalArticle.getId());
30614                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
30615                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
30616                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
30617                    journalArticleImpl.setUserId(journalArticle.getUserId());
30618                    journalArticleImpl.setUserName(journalArticle.getUserName());
30619                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
30620                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
30621                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
30622                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
30623                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
30624                    journalArticleImpl.setTreePath(journalArticle.getTreePath());
30625                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
30626                    journalArticleImpl.setVersion(journalArticle.getVersion());
30627                    journalArticleImpl.setTitle(journalArticle.getTitle());
30628                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
30629                    journalArticleImpl.setDescription(journalArticle.getDescription());
30630                    journalArticleImpl.setContent(journalArticle.getContent());
30631                    journalArticleImpl.setType(journalArticle.getType());
30632                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
30633                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
30634                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
30635                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
30636                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
30637                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
30638                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
30639                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
30640                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
30641                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
30642                    journalArticleImpl.setStatus(journalArticle.getStatus());
30643                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
30644                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
30645                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
30646    
30647                    return journalArticleImpl;
30648            }
30649    
30650            /**
30651             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
30652             *
30653             * @param primaryKey the primary key of the journal article
30654             * @return the journal article
30655             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
30656             * @throws SystemException if a system exception occurred
30657             */
30658            @Override
30659            public JournalArticle findByPrimaryKey(Serializable primaryKey)
30660                    throws NoSuchArticleException, SystemException {
30661                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
30662    
30663                    if (journalArticle == null) {
30664                            if (_log.isWarnEnabled()) {
30665                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
30666                            }
30667    
30668                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
30669                                    primaryKey);
30670                    }
30671    
30672                    return journalArticle;
30673            }
30674    
30675            /**
30676             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
30677             *
30678             * @param id the primary key of the journal article
30679             * @return the journal article
30680             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
30681             * @throws SystemException if a system exception occurred
30682             */
30683            @Override
30684            public JournalArticle findByPrimaryKey(long id)
30685                    throws NoSuchArticleException, SystemException {
30686                    return findByPrimaryKey((Serializable)id);
30687            }
30688    
30689            /**
30690             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
30691             *
30692             * @param primaryKey the primary key of the journal article
30693             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
30694             * @throws SystemException if a system exception occurred
30695             */
30696            @Override
30697            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
30698                    throws SystemException {
30699                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30700                                    JournalArticleImpl.class, primaryKey);
30701    
30702                    if (journalArticle == _nullJournalArticle) {
30703                            return null;
30704                    }
30705    
30706                    if (journalArticle == null) {
30707                            Session session = null;
30708    
30709                            try {
30710                                    session = openSession();
30711    
30712                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
30713                                                    primaryKey);
30714    
30715                                    if (journalArticle != null) {
30716                                            cacheResult(journalArticle);
30717                                    }
30718                                    else {
30719                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30720                                                    JournalArticleImpl.class, primaryKey,
30721                                                    _nullJournalArticle);
30722                                    }
30723                            }
30724                            catch (Exception e) {
30725                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30726                                            JournalArticleImpl.class, primaryKey);
30727    
30728                                    throw processException(e);
30729                            }
30730                            finally {
30731                                    closeSession(session);
30732                            }
30733                    }
30734    
30735                    return journalArticle;
30736            }
30737    
30738            /**
30739             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
30740             *
30741             * @param id the primary key of the journal article
30742             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
30743             * @throws SystemException if a system exception occurred
30744             */
30745            @Override
30746            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
30747                    return fetchByPrimaryKey((Serializable)id);
30748            }
30749    
30750            /**
30751             * Returns all the journal articles.
30752             *
30753             * @return the journal articles
30754             * @throws SystemException if a system exception occurred
30755             */
30756            @Override
30757            public List<JournalArticle> findAll() throws SystemException {
30758                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
30759            }
30760    
30761            /**
30762             * Returns a range of all the journal articles.
30763             *
30764             * <p>
30765             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
30766             * </p>
30767             *
30768             * @param start the lower bound of the range of journal articles
30769             * @param end the upper bound of the range of journal articles (not inclusive)
30770             * @return the range of journal articles
30771             * @throws SystemException if a system exception occurred
30772             */
30773            @Override
30774            public List<JournalArticle> findAll(int start, int end)
30775                    throws SystemException {
30776                    return findAll(start, end, null);
30777            }
30778    
30779            /**
30780             * Returns an ordered range of all the journal articles.
30781             *
30782             * <p>
30783             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
30784             * </p>
30785             *
30786             * @param start the lower bound of the range of journal articles
30787             * @param end the upper bound of the range of journal articles (not inclusive)
30788             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
30789             * @return the ordered range of journal articles
30790             * @throws SystemException if a system exception occurred
30791             */
30792            @Override
30793            public List<JournalArticle> findAll(int start, int end,
30794                    OrderByComparator orderByComparator) throws SystemException {
30795                    boolean pagination = true;
30796                    FinderPath finderPath = null;
30797                    Object[] finderArgs = null;
30798    
30799                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
30800                                    (orderByComparator == null)) {
30801                            pagination = false;
30802                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
30803                            finderArgs = FINDER_ARGS_EMPTY;
30804                    }
30805                    else {
30806                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
30807                            finderArgs = new Object[] { start, end, orderByComparator };
30808                    }
30809    
30810                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
30811                                    finderArgs, this);
30812    
30813                    if (list == null) {
30814                            StringBundler query = null;
30815                            String sql = null;
30816    
30817                            if (orderByComparator != null) {
30818                                    query = new StringBundler(2 +
30819                                                    (orderByComparator.getOrderByFields().length * 3));
30820    
30821                                    query.append(_SQL_SELECT_JOURNALARTICLE);
30822    
30823                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
30824                                            orderByComparator);
30825    
30826                                    sql = query.toString();
30827                            }
30828                            else {
30829                                    sql = _SQL_SELECT_JOURNALARTICLE;
30830    
30831                                    if (pagination) {
30832                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
30833                                    }
30834                            }
30835    
30836                            Session session = null;
30837    
30838                            try {
30839                                    session = openSession();
30840    
30841                                    Query q = session.createQuery(sql);
30842    
30843                                    if (!pagination) {
30844                                            list = (List<JournalArticle>)QueryUtil.list(q,
30845                                                            getDialect(), start, end, false);
30846    
30847                                            Collections.sort(list);
30848    
30849                                            list = new UnmodifiableList<JournalArticle>(list);
30850                                    }
30851                                    else {
30852                                            list = (List<JournalArticle>)QueryUtil.list(q,
30853                                                            getDialect(), start, end);
30854                                    }
30855    
30856                                    cacheResult(list);
30857    
30858                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
30859                            }
30860                            catch (Exception e) {
30861                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
30862    
30863                                    throw processException(e);
30864                            }
30865                            finally {
30866                                    closeSession(session);
30867                            }
30868                    }
30869    
30870                    return list;
30871            }
30872    
30873            /**
30874             * Removes all the journal articles from the database.
30875             *
30876             * @throws SystemException if a system exception occurred
30877             */
30878            @Override
30879            public void removeAll() throws SystemException {
30880                    for (JournalArticle journalArticle : findAll()) {
30881                            remove(journalArticle);
30882                    }
30883            }
30884    
30885            /**
30886             * Returns the number of journal articles.
30887             *
30888             * @return the number of journal articles
30889             * @throws SystemException if a system exception occurred
30890             */
30891            @Override
30892            public int countAll() throws SystemException {
30893                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
30894                                    FINDER_ARGS_EMPTY, this);
30895    
30896                    if (count == null) {
30897                            Session session = null;
30898    
30899                            try {
30900                                    session = openSession();
30901    
30902                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
30903    
30904                                    count = (Long)q.uniqueResult();
30905    
30906                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
30907                                            FINDER_ARGS_EMPTY, count);
30908                            }
30909                            catch (Exception e) {
30910                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
30911                                            FINDER_ARGS_EMPTY);
30912    
30913                                    throw processException(e);
30914                            }
30915                            finally {
30916                                    closeSession(session);
30917                            }
30918                    }
30919    
30920                    return count.intValue();
30921            }
30922    
30923            @Override
30924            protected Set<String> getBadColumnNames() {
30925                    return _badColumnNames;
30926            }
30927    
30928            /**
30929             * Initializes the journal article persistence.
30930             */
30931            public void afterPropertiesSet() {
30932                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
30933                                            com.liferay.portal.util.PropsUtil.get(
30934                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
30935    
30936                    if (listenerClassNames.length > 0) {
30937                            try {
30938                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
30939    
30940                                    for (String listenerClassName : listenerClassNames) {
30941                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
30942                                                            getClassLoader(), listenerClassName));
30943                                    }
30944    
30945                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
30946                            }
30947                            catch (Exception e) {
30948                                    _log.error(e);
30949                            }
30950                    }
30951            }
30952    
30953            public void destroy() {
30954                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
30955                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
30956                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
30957                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
30958            }
30959    
30960            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
30961            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
30962            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
30963            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
30964            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
30965            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
30966            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
30967                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
30968            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
30969                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
30970            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
30971            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
30972            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
30973            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
30974            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
30975            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
30976            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
30977            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
30978            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
30979            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
30980                                    "uuid", "id", "type"
30981                            });
30982            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
30983                            @Override
30984                            public Object clone() {
30985                                    return this;
30986                            }
30987    
30988                            @Override
30989                            public CacheModel<JournalArticle> toCacheModel() {
30990                                    return _nullJournalArticleCacheModel;
30991                            }
30992                    };
30993    
30994            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
30995                            @Override
30996                            public JournalArticle toEntityModel() {
30997                                    return _nullJournalArticle;
30998                            }
30999                    };
31000    }