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    
051    import java.io.Serializable;
052    
053    import java.util.ArrayList;
054    import java.util.Collections;
055    import java.util.Date;
056    import java.util.List;
057    import java.util.Set;
058    
059    /**
060     * The persistence implementation for the journal article service.
061     *
062     * <p>
063     * Caching information and settings can be found in <code>portal.properties</code>
064     * </p>
065     *
066     * @author Brian Wing Shun Chan
067     * @see JournalArticlePersistence
068     * @see JournalArticleUtil
069     * @generated
070     */
071    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
072            implements JournalArticlePersistence {
073            /*
074             * NOTE FOR DEVELOPERS:
075             *
076             * 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.
077             */
078            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
079            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List1";
081            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List2";
083            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
084                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
085                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
086                            "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
088                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
089                            JournalArticleImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
092                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
096                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
097                            "findByUuid",
098                            new String[] {
099                                    String.class.getName(),
100                                    
101                            Integer.class.getName(), Integer.class.getName(),
102                                    OrderByComparator.class.getName()
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
105                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
106                            JournalArticleImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108                            new String[] { String.class.getName() },
109                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
110                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
111                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
113                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
115                            new String[] { String.class.getName() });
116    
117            /**
118             * Returns all the journal articles where uuid = &#63;.
119             *
120             * @param uuid the uuid
121             * @return the matching journal articles
122             * @throws SystemException if a system exception occurred
123             */
124            @Override
125            public List<JournalArticle> findByUuid(String uuid)
126                    throws SystemException {
127                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
128            }
129    
130            /**
131             * Returns a range of all the journal articles where uuid = &#63;.
132             *
133             * <p>
134             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
135             * </p>
136             *
137             * @param uuid the uuid
138             * @param start the lower bound of the range of journal articles
139             * @param end the upper bound of the range of journal articles (not inclusive)
140             * @return the range of matching journal articles
141             * @throws SystemException if a system exception occurred
142             */
143            @Override
144            public List<JournalArticle> findByUuid(String uuid, int start, int end)
145                    throws SystemException {
146                    return findByUuid(uuid, start, end, null);
147            }
148    
149            /**
150             * Returns an ordered range of all the journal articles where uuid = &#63;.
151             *
152             * <p>
153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
154             * </p>
155             *
156             * @param uuid the uuid
157             * @param start the lower bound of the range of journal articles
158             * @param end the upper bound of the range of journal articles (not inclusive)
159             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
160             * @return the ordered range of matching journal articles
161             * @throws SystemException if a system exception occurred
162             */
163            @Override
164            public List<JournalArticle> findByUuid(String uuid, int start, int end,
165                    OrderByComparator orderByComparator) throws SystemException {
166                    boolean pagination = true;
167                    FinderPath finderPath = null;
168                    Object[] finderArgs = null;
169    
170                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
171                                    (orderByComparator == null)) {
172                            pagination = false;
173                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
174                            finderArgs = new Object[] { uuid };
175                    }
176                    else {
177                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
178                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
179                    }
180    
181                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
182                                    finderArgs, this);
183    
184                    if ((list != null) && !list.isEmpty()) {
185                            for (JournalArticle journalArticle : list) {
186                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
187                                            list = null;
188    
189                                            break;
190                                    }
191                            }
192                    }
193    
194                    if (list == null) {
195                            StringBundler query = null;
196    
197                            if (orderByComparator != null) {
198                                    query = new StringBundler(3 +
199                                                    (orderByComparator.getOrderByFields().length * 3));
200                            }
201                            else {
202                                    query = new StringBundler(3);
203                            }
204    
205                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
206    
207                            boolean bindUuid = false;
208    
209                            if (uuid == null) {
210                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
211                            }
212                            else if (uuid.equals(StringPool.BLANK)) {
213                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
214                            }
215                            else {
216                                    bindUuid = true;
217    
218                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
219                            }
220    
221                            if (orderByComparator != null) {
222                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
223                                            orderByComparator);
224                            }
225                            else
226                             if (pagination) {
227                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
228                            }
229    
230                            String sql = query.toString();
231    
232                            Session session = null;
233    
234                            try {
235                                    session = openSession();
236    
237                                    Query q = session.createQuery(sql);
238    
239                                    QueryPos qPos = QueryPos.getInstance(q);
240    
241                                    if (bindUuid) {
242                                            qPos.add(uuid);
243                                    }
244    
245                                    if (!pagination) {
246                                            list = (List<JournalArticle>)QueryUtil.list(q,
247                                                            getDialect(), start, end, false);
248    
249                                            Collections.sort(list);
250    
251                                            list = new UnmodifiableList<JournalArticle>(list);
252                                    }
253                                    else {
254                                            list = (List<JournalArticle>)QueryUtil.list(q,
255                                                            getDialect(), start, end);
256                                    }
257    
258                                    cacheResult(list);
259    
260                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
261                            }
262                            catch (Exception e) {
263                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
264    
265                                    throw processException(e);
266                            }
267                            finally {
268                                    closeSession(session);
269                            }
270                    }
271    
272                    return list;
273            }
274    
275            /**
276             * Returns the first journal article in the ordered set where uuid = &#63;.
277             *
278             * @param uuid the uuid
279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
280             * @return the first matching journal article
281             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
282             * @throws SystemException if a system exception occurred
283             */
284            @Override
285            public JournalArticle findByUuid_First(String uuid,
286                    OrderByComparator orderByComparator)
287                    throws NoSuchArticleException, SystemException {
288                    JournalArticle journalArticle = fetchByUuid_First(uuid,
289                                    orderByComparator);
290    
291                    if (journalArticle != null) {
292                            return journalArticle;
293                    }
294    
295                    StringBundler msg = new StringBundler(4);
296    
297                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
298    
299                    msg.append("uuid=");
300                    msg.append(uuid);
301    
302                    msg.append(StringPool.CLOSE_CURLY_BRACE);
303    
304                    throw new NoSuchArticleException(msg.toString());
305            }
306    
307            /**
308             * Returns the first journal article in the ordered set where uuid = &#63;.
309             *
310             * @param uuid the uuid
311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
312             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
313             * @throws SystemException if a system exception occurred
314             */
315            @Override
316            public JournalArticle fetchByUuid_First(String uuid,
317                    OrderByComparator orderByComparator) throws SystemException {
318                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
319    
320                    if (!list.isEmpty()) {
321                            return list.get(0);
322                    }
323    
324                    return null;
325            }
326    
327            /**
328             * Returns the last journal article in the ordered set where uuid = &#63;.
329             *
330             * @param uuid the uuid
331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
332             * @return the last matching journal article
333             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
334             * @throws SystemException if a system exception occurred
335             */
336            @Override
337            public JournalArticle findByUuid_Last(String uuid,
338                    OrderByComparator orderByComparator)
339                    throws NoSuchArticleException, SystemException {
340                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
341    
342                    if (journalArticle != null) {
343                            return journalArticle;
344                    }
345    
346                    StringBundler msg = new StringBundler(4);
347    
348                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
349    
350                    msg.append("uuid=");
351                    msg.append(uuid);
352    
353                    msg.append(StringPool.CLOSE_CURLY_BRACE);
354    
355                    throw new NoSuchArticleException(msg.toString());
356            }
357    
358            /**
359             * Returns the last journal article in the ordered set where uuid = &#63;.
360             *
361             * @param uuid the uuid
362             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
363             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
364             * @throws SystemException if a system exception occurred
365             */
366            @Override
367            public JournalArticle fetchByUuid_Last(String uuid,
368                    OrderByComparator orderByComparator) throws SystemException {
369                    int count = countByUuid(uuid);
370    
371                    if (count == 0) {
372                            return null;
373                    }
374    
375                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
376                                    orderByComparator);
377    
378                    if (!list.isEmpty()) {
379                            return list.get(0);
380                    }
381    
382                    return null;
383            }
384    
385            /**
386             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
387             *
388             * @param id the primary key of the current journal article
389             * @param uuid the uuid
390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
391             * @return the previous, current, and next journal article
392             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
393             * @throws SystemException if a system exception occurred
394             */
395            @Override
396            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
397                    OrderByComparator orderByComparator)
398                    throws NoSuchArticleException, SystemException {
399                    JournalArticle journalArticle = findByPrimaryKey(id);
400    
401                    Session session = null;
402    
403                    try {
404                            session = openSession();
405    
406                            JournalArticle[] array = new JournalArticleImpl[3];
407    
408                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
409                                            orderByComparator, true);
410    
411                            array[1] = journalArticle;
412    
413                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
414                                            orderByComparator, false);
415    
416                            return array;
417                    }
418                    catch (Exception e) {
419                            throw processException(e);
420                    }
421                    finally {
422                            closeSession(session);
423                    }
424            }
425    
426            protected JournalArticle getByUuid_PrevAndNext(Session session,
427                    JournalArticle journalArticle, String uuid,
428                    OrderByComparator orderByComparator, boolean previous) {
429                    StringBundler query = null;
430    
431                    if (orderByComparator != null) {
432                            query = new StringBundler(6 +
433                                            (orderByComparator.getOrderByFields().length * 6));
434                    }
435                    else {
436                            query = new StringBundler(3);
437                    }
438    
439                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
440    
441                    boolean bindUuid = false;
442    
443                    if (uuid == null) {
444                            query.append(_FINDER_COLUMN_UUID_UUID_1);
445                    }
446                    else if (uuid.equals(StringPool.BLANK)) {
447                            query.append(_FINDER_COLUMN_UUID_UUID_3);
448                    }
449                    else {
450                            bindUuid = true;
451    
452                            query.append(_FINDER_COLUMN_UUID_UUID_2);
453                    }
454    
455                    if (orderByComparator != null) {
456                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
457    
458                            if (orderByConditionFields.length > 0) {
459                                    query.append(WHERE_AND);
460                            }
461    
462                            for (int i = 0; i < orderByConditionFields.length; i++) {
463                                    query.append(_ORDER_BY_ENTITY_ALIAS);
464                                    query.append(orderByConditionFields[i]);
465    
466                                    if ((i + 1) < orderByConditionFields.length) {
467                                            if (orderByComparator.isAscending() ^ previous) {
468                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
469                                            }
470                                            else {
471                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
472                                            }
473                                    }
474                                    else {
475                                            if (orderByComparator.isAscending() ^ previous) {
476                                                    query.append(WHERE_GREATER_THAN);
477                                            }
478                                            else {
479                                                    query.append(WHERE_LESSER_THAN);
480                                            }
481                                    }
482                            }
483    
484                            query.append(ORDER_BY_CLAUSE);
485    
486                            String[] orderByFields = orderByComparator.getOrderByFields();
487    
488                            for (int i = 0; i < orderByFields.length; i++) {
489                                    query.append(_ORDER_BY_ENTITY_ALIAS);
490                                    query.append(orderByFields[i]);
491    
492                                    if ((i + 1) < orderByFields.length) {
493                                            if (orderByComparator.isAscending() ^ previous) {
494                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
495                                            }
496                                            else {
497                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
498                                            }
499                                    }
500                                    else {
501                                            if (orderByComparator.isAscending() ^ previous) {
502                                                    query.append(ORDER_BY_ASC);
503                                            }
504                                            else {
505                                                    query.append(ORDER_BY_DESC);
506                                            }
507                                    }
508                            }
509                    }
510                    else {
511                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
512                    }
513    
514                    String sql = query.toString();
515    
516                    Query q = session.createQuery(sql);
517    
518                    q.setFirstResult(0);
519                    q.setMaxResults(2);
520    
521                    QueryPos qPos = QueryPos.getInstance(q);
522    
523                    if (bindUuid) {
524                            qPos.add(uuid);
525                    }
526    
527                    if (orderByComparator != null) {
528                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
529    
530                            for (Object value : values) {
531                                    qPos.add(value);
532                            }
533                    }
534    
535                    List<JournalArticle> list = q.list();
536    
537                    if (list.size() == 2) {
538                            return list.get(1);
539                    }
540                    else {
541                            return null;
542                    }
543            }
544    
545            /**
546             * Removes all the journal articles where uuid = &#63; from the database.
547             *
548             * @param uuid the uuid
549             * @throws SystemException if a system exception occurred
550             */
551            @Override
552            public void removeByUuid(String uuid) throws SystemException {
553                    for (JournalArticle journalArticle : findByUuid(uuid,
554                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
555                            remove(journalArticle);
556                    }
557            }
558    
559            /**
560             * Returns the number of journal articles where uuid = &#63;.
561             *
562             * @param uuid the uuid
563             * @return the number of matching journal articles
564             * @throws SystemException if a system exception occurred
565             */
566            @Override
567            public int countByUuid(String uuid) throws SystemException {
568                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
569    
570                    Object[] finderArgs = new Object[] { uuid };
571    
572                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
573                                    this);
574    
575                    if (count == null) {
576                            StringBundler query = new StringBundler(2);
577    
578                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
579    
580                            boolean bindUuid = false;
581    
582                            if (uuid == null) {
583                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
584                            }
585                            else if (uuid.equals(StringPool.BLANK)) {
586                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
587                            }
588                            else {
589                                    bindUuid = true;
590    
591                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
592                            }
593    
594                            String sql = query.toString();
595    
596                            Session session = null;
597    
598                            try {
599                                    session = openSession();
600    
601                                    Query q = session.createQuery(sql);
602    
603                                    QueryPos qPos = QueryPos.getInstance(q);
604    
605                                    if (bindUuid) {
606                                            qPos.add(uuid);
607                                    }
608    
609                                    count = (Long)q.uniqueResult();
610    
611                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
612                            }
613                            catch (Exception e) {
614                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
615    
616                                    throw processException(e);
617                            }
618                            finally {
619                                    closeSession(session);
620                            }
621                    }
622    
623                    return count.intValue();
624            }
625    
626            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
627            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
628            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '')";
629            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
630                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
631                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
632                            "fetchByUUID_G",
633                            new String[] { String.class.getName(), Long.class.getName() },
634                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
635                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
636            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
637                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
638                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
639                            new String[] { String.class.getName(), Long.class.getName() });
640    
641            /**
642             * 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.
643             *
644             * @param uuid the uuid
645             * @param groupId the group ID
646             * @return the matching journal article
647             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
648             * @throws SystemException if a system exception occurred
649             */
650            @Override
651            public JournalArticle findByUUID_G(String uuid, long groupId)
652                    throws NoSuchArticleException, SystemException {
653                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
654    
655                    if (journalArticle == null) {
656                            StringBundler msg = new StringBundler(6);
657    
658                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
659    
660                            msg.append("uuid=");
661                            msg.append(uuid);
662    
663                            msg.append(", groupId=");
664                            msg.append(groupId);
665    
666                            msg.append(StringPool.CLOSE_CURLY_BRACE);
667    
668                            if (_log.isWarnEnabled()) {
669                                    _log.warn(msg.toString());
670                            }
671    
672                            throw new NoSuchArticleException(msg.toString());
673                    }
674    
675                    return journalArticle;
676            }
677    
678            /**
679             * 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.
680             *
681             * @param uuid the uuid
682             * @param groupId the group ID
683             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
684             * @throws SystemException if a system exception occurred
685             */
686            @Override
687            public JournalArticle fetchByUUID_G(String uuid, long groupId)
688                    throws SystemException {
689                    return fetchByUUID_G(uuid, groupId, true);
690            }
691    
692            /**
693             * 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.
694             *
695             * @param uuid the uuid
696             * @param groupId the group ID
697             * @param retrieveFromCache whether to use the finder cache
698             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
699             * @throws SystemException if a system exception occurred
700             */
701            @Override
702            public JournalArticle fetchByUUID_G(String uuid, long groupId,
703                    boolean retrieveFromCache) throws SystemException {
704                    Object[] finderArgs = new Object[] { uuid, groupId };
705    
706                    Object result = null;
707    
708                    if (retrieveFromCache) {
709                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
710                                            finderArgs, this);
711                    }
712    
713                    if (result instanceof JournalArticle) {
714                            JournalArticle journalArticle = (JournalArticle)result;
715    
716                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
717                                            (groupId != journalArticle.getGroupId())) {
718                                    result = null;
719                            }
720                    }
721    
722                    if (result == null) {
723                            StringBundler query = new StringBundler(4);
724    
725                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
726    
727                            boolean bindUuid = false;
728    
729                            if (uuid == null) {
730                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
731                            }
732                            else if (uuid.equals(StringPool.BLANK)) {
733                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
734                            }
735                            else {
736                                    bindUuid = true;
737    
738                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
739                            }
740    
741                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
742    
743                            String sql = query.toString();
744    
745                            Session session = null;
746    
747                            try {
748                                    session = openSession();
749    
750                                    Query q = session.createQuery(sql);
751    
752                                    QueryPos qPos = QueryPos.getInstance(q);
753    
754                                    if (bindUuid) {
755                                            qPos.add(uuid);
756                                    }
757    
758                                    qPos.add(groupId);
759    
760                                    List<JournalArticle> list = q.list();
761    
762                                    if (list.isEmpty()) {
763                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
764                                                    finderArgs, list);
765                                    }
766                                    else {
767                                            JournalArticle journalArticle = list.get(0);
768    
769                                            result = journalArticle;
770    
771                                            cacheResult(journalArticle);
772    
773                                            if ((journalArticle.getUuid() == null) ||
774                                                            !journalArticle.getUuid().equals(uuid) ||
775                                                            (journalArticle.getGroupId() != groupId)) {
776                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
777                                                            finderArgs, journalArticle);
778                                            }
779                                    }
780                            }
781                            catch (Exception e) {
782                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
783                                            finderArgs);
784    
785                                    throw processException(e);
786                            }
787                            finally {
788                                    closeSession(session);
789                            }
790                    }
791    
792                    if (result instanceof List<?>) {
793                            return null;
794                    }
795                    else {
796                            return (JournalArticle)result;
797                    }
798            }
799    
800            /**
801             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
802             *
803             * @param uuid the uuid
804             * @param groupId the group ID
805             * @return the journal article that was removed
806             * @throws SystemException if a system exception occurred
807             */
808            @Override
809            public JournalArticle removeByUUID_G(String uuid, long groupId)
810                    throws NoSuchArticleException, SystemException {
811                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
812    
813                    return remove(journalArticle);
814            }
815    
816            /**
817             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
818             *
819             * @param uuid the uuid
820             * @param groupId the group ID
821             * @return the number of matching journal articles
822             * @throws SystemException if a system exception occurred
823             */
824            @Override
825            public int countByUUID_G(String uuid, long groupId)
826                    throws SystemException {
827                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
828    
829                    Object[] finderArgs = new Object[] { uuid, groupId };
830    
831                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
832                                    this);
833    
834                    if (count == null) {
835                            StringBundler query = new StringBundler(3);
836    
837                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
838    
839                            boolean bindUuid = false;
840    
841                            if (uuid == null) {
842                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
843                            }
844                            else if (uuid.equals(StringPool.BLANK)) {
845                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
846                            }
847                            else {
848                                    bindUuid = true;
849    
850                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
851                            }
852    
853                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
854    
855                            String sql = query.toString();
856    
857                            Session session = null;
858    
859                            try {
860                                    session = openSession();
861    
862                                    Query q = session.createQuery(sql);
863    
864                                    QueryPos qPos = QueryPos.getInstance(q);
865    
866                                    if (bindUuid) {
867                                            qPos.add(uuid);
868                                    }
869    
870                                    qPos.add(groupId);
871    
872                                    count = (Long)q.uniqueResult();
873    
874                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
875                            }
876                            catch (Exception e) {
877                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
878    
879                                    throw processException(e);
880                            }
881                            finally {
882                                    closeSession(session);
883                            }
884                    }
885    
886                    return count.intValue();
887            }
888    
889            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
890            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
891            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
892            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
893            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
894                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
895                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
896                            "findByUuid_C",
897                            new String[] {
898                                    String.class.getName(), Long.class.getName(),
899                                    
900                            Integer.class.getName(), Integer.class.getName(),
901                                    OrderByComparator.class.getName()
902                            });
903            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
904                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
905                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
906                            JournalArticleImpl.class,
907                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
908                            new String[] { String.class.getName(), Long.class.getName() },
909                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
910                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
911                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
912                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
913            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
914                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
915                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
916                            new String[] { String.class.getName(), Long.class.getName() });
917    
918            /**
919             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
920             *
921             * @param uuid the uuid
922             * @param companyId the company ID
923             * @return the matching journal articles
924             * @throws SystemException if a system exception occurred
925             */
926            @Override
927            public List<JournalArticle> findByUuid_C(String uuid, long companyId)
928                    throws SystemException {
929                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
930                            QueryUtil.ALL_POS, null);
931            }
932    
933            /**
934             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
935             *
936             * <p>
937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
938             * </p>
939             *
940             * @param uuid the uuid
941             * @param companyId the company ID
942             * @param start the lower bound of the range of journal articles
943             * @param end the upper bound of the range of journal articles (not inclusive)
944             * @return the range of matching journal articles
945             * @throws SystemException if a system exception occurred
946             */
947            @Override
948            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
949                    int start, int end) throws SystemException {
950                    return findByUuid_C(uuid, companyId, start, end, null);
951            }
952    
953            /**
954             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
955             *
956             * <p>
957             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
958             * </p>
959             *
960             * @param uuid the uuid
961             * @param companyId the company ID
962             * @param start the lower bound of the range of journal articles
963             * @param end the upper bound of the range of journal articles (not inclusive)
964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
965             * @return the ordered range of matching journal articles
966             * @throws SystemException if a system exception occurred
967             */
968            @Override
969            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
970                    int start, int end, OrderByComparator orderByComparator)
971                    throws SystemException {
972                    boolean pagination = true;
973                    FinderPath finderPath = null;
974                    Object[] finderArgs = null;
975    
976                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
977                                    (orderByComparator == null)) {
978                            pagination = false;
979                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
980                            finderArgs = new Object[] { uuid, companyId };
981                    }
982                    else {
983                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
984                            finderArgs = new Object[] {
985                                            uuid, companyId,
986                                            
987                                            start, end, orderByComparator
988                                    };
989                    }
990    
991                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
992                                    finderArgs, this);
993    
994                    if ((list != null) && !list.isEmpty()) {
995                            for (JournalArticle journalArticle : list) {
996                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
997                                                    (companyId != journalArticle.getCompanyId())) {
998                                            list = null;
999    
1000                                            break;
1001                                    }
1002                            }
1003                    }
1004    
1005                    if (list == null) {
1006                            StringBundler query = null;
1007    
1008                            if (orderByComparator != null) {
1009                                    query = new StringBundler(4 +
1010                                                    (orderByComparator.getOrderByFields().length * 3));
1011                            }
1012                            else {
1013                                    query = new StringBundler(4);
1014                            }
1015    
1016                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1017    
1018                            boolean bindUuid = false;
1019    
1020                            if (uuid == null) {
1021                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1022                            }
1023                            else if (uuid.equals(StringPool.BLANK)) {
1024                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1025                            }
1026                            else {
1027                                    bindUuid = true;
1028    
1029                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1030                            }
1031    
1032                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1033    
1034                            if (orderByComparator != null) {
1035                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1036                                            orderByComparator);
1037                            }
1038                            else
1039                             if (pagination) {
1040                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1041                            }
1042    
1043                            String sql = query.toString();
1044    
1045                            Session session = null;
1046    
1047                            try {
1048                                    session = openSession();
1049    
1050                                    Query q = session.createQuery(sql);
1051    
1052                                    QueryPos qPos = QueryPos.getInstance(q);
1053    
1054                                    if (bindUuid) {
1055                                            qPos.add(uuid);
1056                                    }
1057    
1058                                    qPos.add(companyId);
1059    
1060                                    if (!pagination) {
1061                                            list = (List<JournalArticle>)QueryUtil.list(q,
1062                                                            getDialect(), start, end, false);
1063    
1064                                            Collections.sort(list);
1065    
1066                                            list = new UnmodifiableList<JournalArticle>(list);
1067                                    }
1068                                    else {
1069                                            list = (List<JournalArticle>)QueryUtil.list(q,
1070                                                            getDialect(), start, end);
1071                                    }
1072    
1073                                    cacheResult(list);
1074    
1075                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1076                            }
1077                            catch (Exception e) {
1078                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1079    
1080                                    throw processException(e);
1081                            }
1082                            finally {
1083                                    closeSession(session);
1084                            }
1085                    }
1086    
1087                    return list;
1088            }
1089    
1090            /**
1091             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1092             *
1093             * @param uuid the uuid
1094             * @param companyId the company ID
1095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1096             * @return the first matching journal article
1097             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1098             * @throws SystemException if a system exception occurred
1099             */
1100            @Override
1101            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1102                    OrderByComparator orderByComparator)
1103                    throws NoSuchArticleException, SystemException {
1104                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1105                                    orderByComparator);
1106    
1107                    if (journalArticle != null) {
1108                            return journalArticle;
1109                    }
1110    
1111                    StringBundler msg = new StringBundler(6);
1112    
1113                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1114    
1115                    msg.append("uuid=");
1116                    msg.append(uuid);
1117    
1118                    msg.append(", companyId=");
1119                    msg.append(companyId);
1120    
1121                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1122    
1123                    throw new NoSuchArticleException(msg.toString());
1124            }
1125    
1126            /**
1127             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1128             *
1129             * @param uuid the uuid
1130             * @param companyId the company ID
1131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1132             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            @Override
1136            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1137                    OrderByComparator orderByComparator) throws SystemException {
1138                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1139                                    orderByComparator);
1140    
1141                    if (!list.isEmpty()) {
1142                            return list.get(0);
1143                    }
1144    
1145                    return null;
1146            }
1147    
1148            /**
1149             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1150             *
1151             * @param uuid the uuid
1152             * @param companyId the company ID
1153             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1154             * @return the last matching journal article
1155             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            @Override
1159            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1160                    OrderByComparator orderByComparator)
1161                    throws NoSuchArticleException, SystemException {
1162                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1163                                    orderByComparator);
1164    
1165                    if (journalArticle != null) {
1166                            return journalArticle;
1167                    }
1168    
1169                    StringBundler msg = new StringBundler(6);
1170    
1171                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1172    
1173                    msg.append("uuid=");
1174                    msg.append(uuid);
1175    
1176                    msg.append(", companyId=");
1177                    msg.append(companyId);
1178    
1179                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1180    
1181                    throw new NoSuchArticleException(msg.toString());
1182            }
1183    
1184            /**
1185             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1186             *
1187             * @param uuid the uuid
1188             * @param companyId the company ID
1189             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1190             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1191             * @throws SystemException if a system exception occurred
1192             */
1193            @Override
1194            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1195                    OrderByComparator orderByComparator) throws SystemException {
1196                    int count = countByUuid_C(uuid, companyId);
1197    
1198                    if (count == 0) {
1199                            return null;
1200                    }
1201    
1202                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1203                                    count, orderByComparator);
1204    
1205                    if (!list.isEmpty()) {
1206                            return list.get(0);
1207                    }
1208    
1209                    return null;
1210            }
1211    
1212            /**
1213             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1214             *
1215             * @param id the primary key of the current journal article
1216             * @param uuid the uuid
1217             * @param companyId the company ID
1218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1219             * @return the previous, current, and next journal article
1220             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1221             * @throws SystemException if a system exception occurred
1222             */
1223            @Override
1224            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1225                    long companyId, OrderByComparator orderByComparator)
1226                    throws NoSuchArticleException, SystemException {
1227                    JournalArticle journalArticle = findByPrimaryKey(id);
1228    
1229                    Session session = null;
1230    
1231                    try {
1232                            session = openSession();
1233    
1234                            JournalArticle[] array = new JournalArticleImpl[3];
1235    
1236                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1237                                            companyId, orderByComparator, true);
1238    
1239                            array[1] = journalArticle;
1240    
1241                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1242                                            companyId, orderByComparator, false);
1243    
1244                            return array;
1245                    }
1246                    catch (Exception e) {
1247                            throw processException(e);
1248                    }
1249                    finally {
1250                            closeSession(session);
1251                    }
1252            }
1253    
1254            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1255                    JournalArticle journalArticle, String uuid, long companyId,
1256                    OrderByComparator orderByComparator, boolean previous) {
1257                    StringBundler query = null;
1258    
1259                    if (orderByComparator != null) {
1260                            query = new StringBundler(6 +
1261                                            (orderByComparator.getOrderByFields().length * 6));
1262                    }
1263                    else {
1264                            query = new StringBundler(3);
1265                    }
1266    
1267                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1268    
1269                    boolean bindUuid = false;
1270    
1271                    if (uuid == null) {
1272                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1273                    }
1274                    else if (uuid.equals(StringPool.BLANK)) {
1275                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1276                    }
1277                    else {
1278                            bindUuid = true;
1279    
1280                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1281                    }
1282    
1283                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1284    
1285                    if (orderByComparator != null) {
1286                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1287    
1288                            if (orderByConditionFields.length > 0) {
1289                                    query.append(WHERE_AND);
1290                            }
1291    
1292                            for (int i = 0; i < orderByConditionFields.length; i++) {
1293                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1294                                    query.append(orderByConditionFields[i]);
1295    
1296                                    if ((i + 1) < orderByConditionFields.length) {
1297                                            if (orderByComparator.isAscending() ^ previous) {
1298                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1299                                            }
1300                                            else {
1301                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1302                                            }
1303                                    }
1304                                    else {
1305                                            if (orderByComparator.isAscending() ^ previous) {
1306                                                    query.append(WHERE_GREATER_THAN);
1307                                            }
1308                                            else {
1309                                                    query.append(WHERE_LESSER_THAN);
1310                                            }
1311                                    }
1312                            }
1313    
1314                            query.append(ORDER_BY_CLAUSE);
1315    
1316                            String[] orderByFields = orderByComparator.getOrderByFields();
1317    
1318                            for (int i = 0; i < orderByFields.length; i++) {
1319                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1320                                    query.append(orderByFields[i]);
1321    
1322                                    if ((i + 1) < orderByFields.length) {
1323                                            if (orderByComparator.isAscending() ^ previous) {
1324                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1325                                            }
1326                                            else {
1327                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1328                                            }
1329                                    }
1330                                    else {
1331                                            if (orderByComparator.isAscending() ^ previous) {
1332                                                    query.append(ORDER_BY_ASC);
1333                                            }
1334                                            else {
1335                                                    query.append(ORDER_BY_DESC);
1336                                            }
1337                                    }
1338                            }
1339                    }
1340                    else {
1341                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1342                    }
1343    
1344                    String sql = query.toString();
1345    
1346                    Query q = session.createQuery(sql);
1347    
1348                    q.setFirstResult(0);
1349                    q.setMaxResults(2);
1350    
1351                    QueryPos qPos = QueryPos.getInstance(q);
1352    
1353                    if (bindUuid) {
1354                            qPos.add(uuid);
1355                    }
1356    
1357                    qPos.add(companyId);
1358    
1359                    if (orderByComparator != null) {
1360                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1361    
1362                            for (Object value : values) {
1363                                    qPos.add(value);
1364                            }
1365                    }
1366    
1367                    List<JournalArticle> list = q.list();
1368    
1369                    if (list.size() == 2) {
1370                            return list.get(1);
1371                    }
1372                    else {
1373                            return null;
1374                    }
1375            }
1376    
1377            /**
1378             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1379             *
1380             * @param uuid the uuid
1381             * @param companyId the company ID
1382             * @throws SystemException if a system exception occurred
1383             */
1384            @Override
1385            public void removeByUuid_C(String uuid, long companyId)
1386                    throws SystemException {
1387                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1388                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1389                            remove(journalArticle);
1390                    }
1391            }
1392    
1393            /**
1394             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1395             *
1396             * @param uuid the uuid
1397             * @param companyId the company ID
1398             * @return the number of matching journal articles
1399             * @throws SystemException if a system exception occurred
1400             */
1401            @Override
1402            public int countByUuid_C(String uuid, long companyId)
1403                    throws SystemException {
1404                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1405    
1406                    Object[] finderArgs = new Object[] { uuid, companyId };
1407    
1408                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1409                                    this);
1410    
1411                    if (count == null) {
1412                            StringBundler query = new StringBundler(3);
1413    
1414                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1415    
1416                            boolean bindUuid = false;
1417    
1418                            if (uuid == null) {
1419                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1420                            }
1421                            else if (uuid.equals(StringPool.BLANK)) {
1422                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1423                            }
1424                            else {
1425                                    bindUuid = true;
1426    
1427                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1428                            }
1429    
1430                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1431    
1432                            String sql = query.toString();
1433    
1434                            Session session = null;
1435    
1436                            try {
1437                                    session = openSession();
1438    
1439                                    Query q = session.createQuery(sql);
1440    
1441                                    QueryPos qPos = QueryPos.getInstance(q);
1442    
1443                                    if (bindUuid) {
1444                                            qPos.add(uuid);
1445                                    }
1446    
1447                                    qPos.add(companyId);
1448    
1449                                    count = (Long)q.uniqueResult();
1450    
1451                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1452                            }
1453                            catch (Exception e) {
1454                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1455    
1456                                    throw processException(e);
1457                            }
1458                            finally {
1459                                    closeSession(session);
1460                            }
1461                    }
1462    
1463                    return count.intValue();
1464            }
1465    
1466            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1467            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1468            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
1469            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1470            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1471                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1472                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1473                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1474                            "findByResourcePrimKey",
1475                            new String[] {
1476                                    Long.class.getName(),
1477                                    
1478                            Integer.class.getName(), Integer.class.getName(),
1479                                    OrderByComparator.class.getName()
1480                            });
1481            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1482                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1483                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1484                            JournalArticleImpl.class,
1485                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1486                            new String[] { Long.class.getName() },
1487                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1488                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1489                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1490            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1491                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1492                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1493                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1494    
1495            /**
1496             * Returns all the journal articles where resourcePrimKey = &#63;.
1497             *
1498             * @param resourcePrimKey the resource prim key
1499             * @return the matching journal articles
1500             * @throws SystemException if a system exception occurred
1501             */
1502            @Override
1503            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
1504                    throws SystemException {
1505                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1506                            QueryUtil.ALL_POS, null);
1507            }
1508    
1509            /**
1510             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1511             *
1512             * <p>
1513             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1514             * </p>
1515             *
1516             * @param resourcePrimKey the resource prim key
1517             * @param start the lower bound of the range of journal articles
1518             * @param end the upper bound of the range of journal articles (not inclusive)
1519             * @return the range of matching journal articles
1520             * @throws SystemException if a system exception occurred
1521             */
1522            @Override
1523            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1524                    int start, int end) throws SystemException {
1525                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1526            }
1527    
1528            /**
1529             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1530             *
1531             * <p>
1532             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1533             * </p>
1534             *
1535             * @param resourcePrimKey the resource prim key
1536             * @param start the lower bound of the range of journal articles
1537             * @param end the upper bound of the range of journal articles (not inclusive)
1538             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1539             * @return the ordered range of matching journal articles
1540             * @throws SystemException if a system exception occurred
1541             */
1542            @Override
1543            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1544                    int start, int end, OrderByComparator orderByComparator)
1545                    throws SystemException {
1546                    boolean pagination = true;
1547                    FinderPath finderPath = null;
1548                    Object[] finderArgs = null;
1549    
1550                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1551                                    (orderByComparator == null)) {
1552                            pagination = false;
1553                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1554                            finderArgs = new Object[] { resourcePrimKey };
1555                    }
1556                    else {
1557                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1558                            finderArgs = new Object[] {
1559                                            resourcePrimKey,
1560                                            
1561                                            start, end, orderByComparator
1562                                    };
1563                    }
1564    
1565                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1566                                    finderArgs, this);
1567    
1568                    if ((list != null) && !list.isEmpty()) {
1569                            for (JournalArticle journalArticle : list) {
1570                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1571                                            list = null;
1572    
1573                                            break;
1574                                    }
1575                            }
1576                    }
1577    
1578                    if (list == null) {
1579                            StringBundler query = null;
1580    
1581                            if (orderByComparator != null) {
1582                                    query = new StringBundler(3 +
1583                                                    (orderByComparator.getOrderByFields().length * 3));
1584                            }
1585                            else {
1586                                    query = new StringBundler(3);
1587                            }
1588    
1589                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1590    
1591                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1592    
1593                            if (orderByComparator != null) {
1594                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1595                                            orderByComparator);
1596                            }
1597                            else
1598                             if (pagination) {
1599                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1600                            }
1601    
1602                            String sql = query.toString();
1603    
1604                            Session session = null;
1605    
1606                            try {
1607                                    session = openSession();
1608    
1609                                    Query q = session.createQuery(sql);
1610    
1611                                    QueryPos qPos = QueryPos.getInstance(q);
1612    
1613                                    qPos.add(resourcePrimKey);
1614    
1615                                    if (!pagination) {
1616                                            list = (List<JournalArticle>)QueryUtil.list(q,
1617                                                            getDialect(), start, end, false);
1618    
1619                                            Collections.sort(list);
1620    
1621                                            list = new UnmodifiableList<JournalArticle>(list);
1622                                    }
1623                                    else {
1624                                            list = (List<JournalArticle>)QueryUtil.list(q,
1625                                                            getDialect(), start, end);
1626                                    }
1627    
1628                                    cacheResult(list);
1629    
1630                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1631                            }
1632                            catch (Exception e) {
1633                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1634    
1635                                    throw processException(e);
1636                            }
1637                            finally {
1638                                    closeSession(session);
1639                            }
1640                    }
1641    
1642                    return list;
1643            }
1644    
1645            /**
1646             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1647             *
1648             * @param resourcePrimKey the resource prim key
1649             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1650             * @return the first matching journal article
1651             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1652             * @throws SystemException if a system exception occurred
1653             */
1654            @Override
1655            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1656                    OrderByComparator orderByComparator)
1657                    throws NoSuchArticleException, SystemException {
1658                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1659                                    orderByComparator);
1660    
1661                    if (journalArticle != null) {
1662                            return journalArticle;
1663                    }
1664    
1665                    StringBundler msg = new StringBundler(4);
1666    
1667                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1668    
1669                    msg.append("resourcePrimKey=");
1670                    msg.append(resourcePrimKey);
1671    
1672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1673    
1674                    throw new NoSuchArticleException(msg.toString());
1675            }
1676    
1677            /**
1678             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1679             *
1680             * @param resourcePrimKey the resource prim key
1681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1682             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1683             * @throws SystemException if a system exception occurred
1684             */
1685            @Override
1686            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1687                    OrderByComparator orderByComparator) throws SystemException {
1688                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1689                                    1, orderByComparator);
1690    
1691                    if (!list.isEmpty()) {
1692                            return list.get(0);
1693                    }
1694    
1695                    return null;
1696            }
1697    
1698            /**
1699             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1700             *
1701             * @param resourcePrimKey the resource prim key
1702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1703             * @return the last matching journal article
1704             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1705             * @throws SystemException if a system exception occurred
1706             */
1707            @Override
1708            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1709                    OrderByComparator orderByComparator)
1710                    throws NoSuchArticleException, SystemException {
1711                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1712                                    orderByComparator);
1713    
1714                    if (journalArticle != null) {
1715                            return journalArticle;
1716                    }
1717    
1718                    StringBundler msg = new StringBundler(4);
1719    
1720                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1721    
1722                    msg.append("resourcePrimKey=");
1723                    msg.append(resourcePrimKey);
1724    
1725                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1726    
1727                    throw new NoSuchArticleException(msg.toString());
1728            }
1729    
1730            /**
1731             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1732             *
1733             * @param resourcePrimKey the resource prim key
1734             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1735             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1736             * @throws SystemException if a system exception occurred
1737             */
1738            @Override
1739            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1740                    OrderByComparator orderByComparator) throws SystemException {
1741                    int count = countByResourcePrimKey(resourcePrimKey);
1742    
1743                    if (count == 0) {
1744                            return null;
1745                    }
1746    
1747                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1748                                    count - 1, count, orderByComparator);
1749    
1750                    if (!list.isEmpty()) {
1751                            return list.get(0);
1752                    }
1753    
1754                    return null;
1755            }
1756    
1757            /**
1758             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1759             *
1760             * @param id the primary key of the current journal article
1761             * @param resourcePrimKey the resource prim key
1762             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1763             * @return the previous, current, and next journal article
1764             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1765             * @throws SystemException if a system exception occurred
1766             */
1767            @Override
1768            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1769                    long resourcePrimKey, OrderByComparator orderByComparator)
1770                    throws NoSuchArticleException, SystemException {
1771                    JournalArticle journalArticle = findByPrimaryKey(id);
1772    
1773                    Session session = null;
1774    
1775                    try {
1776                            session = openSession();
1777    
1778                            JournalArticle[] array = new JournalArticleImpl[3];
1779    
1780                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1781                                            journalArticle, resourcePrimKey, orderByComparator, true);
1782    
1783                            array[1] = journalArticle;
1784    
1785                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1786                                            journalArticle, resourcePrimKey, orderByComparator, false);
1787    
1788                            return array;
1789                    }
1790                    catch (Exception e) {
1791                            throw processException(e);
1792                    }
1793                    finally {
1794                            closeSession(session);
1795                    }
1796            }
1797    
1798            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1799                    JournalArticle journalArticle, long resourcePrimKey,
1800                    OrderByComparator orderByComparator, boolean previous) {
1801                    StringBundler query = null;
1802    
1803                    if (orderByComparator != null) {
1804                            query = new StringBundler(6 +
1805                                            (orderByComparator.getOrderByFields().length * 6));
1806                    }
1807                    else {
1808                            query = new StringBundler(3);
1809                    }
1810    
1811                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1812    
1813                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1814    
1815                    if (orderByComparator != null) {
1816                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1817    
1818                            if (orderByConditionFields.length > 0) {
1819                                    query.append(WHERE_AND);
1820                            }
1821    
1822                            for (int i = 0; i < orderByConditionFields.length; i++) {
1823                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1824                                    query.append(orderByConditionFields[i]);
1825    
1826                                    if ((i + 1) < orderByConditionFields.length) {
1827                                            if (orderByComparator.isAscending() ^ previous) {
1828                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1829                                            }
1830                                            else {
1831                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1832                                            }
1833                                    }
1834                                    else {
1835                                            if (orderByComparator.isAscending() ^ previous) {
1836                                                    query.append(WHERE_GREATER_THAN);
1837                                            }
1838                                            else {
1839                                                    query.append(WHERE_LESSER_THAN);
1840                                            }
1841                                    }
1842                            }
1843    
1844                            query.append(ORDER_BY_CLAUSE);
1845    
1846                            String[] orderByFields = orderByComparator.getOrderByFields();
1847    
1848                            for (int i = 0; i < orderByFields.length; i++) {
1849                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1850                                    query.append(orderByFields[i]);
1851    
1852                                    if ((i + 1) < orderByFields.length) {
1853                                            if (orderByComparator.isAscending() ^ previous) {
1854                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1855                                            }
1856                                            else {
1857                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1858                                            }
1859                                    }
1860                                    else {
1861                                            if (orderByComparator.isAscending() ^ previous) {
1862                                                    query.append(ORDER_BY_ASC);
1863                                            }
1864                                            else {
1865                                                    query.append(ORDER_BY_DESC);
1866                                            }
1867                                    }
1868                            }
1869                    }
1870                    else {
1871                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1872                    }
1873    
1874                    String sql = query.toString();
1875    
1876                    Query q = session.createQuery(sql);
1877    
1878                    q.setFirstResult(0);
1879                    q.setMaxResults(2);
1880    
1881                    QueryPos qPos = QueryPos.getInstance(q);
1882    
1883                    qPos.add(resourcePrimKey);
1884    
1885                    if (orderByComparator != null) {
1886                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1887    
1888                            for (Object value : values) {
1889                                    qPos.add(value);
1890                            }
1891                    }
1892    
1893                    List<JournalArticle> list = q.list();
1894    
1895                    if (list.size() == 2) {
1896                            return list.get(1);
1897                    }
1898                    else {
1899                            return null;
1900                    }
1901            }
1902    
1903            /**
1904             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1905             *
1906             * @param resourcePrimKey the resource prim key
1907             * @throws SystemException if a system exception occurred
1908             */
1909            @Override
1910            public void removeByResourcePrimKey(long resourcePrimKey)
1911                    throws SystemException {
1912                    for (JournalArticle journalArticle : findByResourcePrimKey(
1913                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1914                            remove(journalArticle);
1915                    }
1916            }
1917    
1918            /**
1919             * Returns the number of journal articles where resourcePrimKey = &#63;.
1920             *
1921             * @param resourcePrimKey the resource prim key
1922             * @return the number of matching journal articles
1923             * @throws SystemException if a system exception occurred
1924             */
1925            @Override
1926            public int countByResourcePrimKey(long resourcePrimKey)
1927                    throws SystemException {
1928                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1929    
1930                    Object[] finderArgs = new Object[] { resourcePrimKey };
1931    
1932                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1933                                    this);
1934    
1935                    if (count == null) {
1936                            StringBundler query = new StringBundler(2);
1937    
1938                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1939    
1940                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1941    
1942                            String sql = query.toString();
1943    
1944                            Session session = null;
1945    
1946                            try {
1947                                    session = openSession();
1948    
1949                                    Query q = session.createQuery(sql);
1950    
1951                                    QueryPos qPos = QueryPos.getInstance(q);
1952    
1953                                    qPos.add(resourcePrimKey);
1954    
1955                                    count = (Long)q.uniqueResult();
1956    
1957                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1958                            }
1959                            catch (Exception e) {
1960                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1961    
1962                                    throw processException(e);
1963                            }
1964                            finally {
1965                                    closeSession(session);
1966                            }
1967                    }
1968    
1969                    return count.intValue();
1970            }
1971    
1972            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1973                    "journalArticle.resourcePrimKey = ?";
1974            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1975                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1976                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1977                            "findByGroupId",
1978                            new String[] {
1979                                    Long.class.getName(),
1980                                    
1981                            Integer.class.getName(), Integer.class.getName(),
1982                                    OrderByComparator.class.getName()
1983                            });
1984            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1985                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1986                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1987                            JournalArticleImpl.class,
1988                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1989                            new String[] { Long.class.getName() },
1990                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1991                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1992                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1993            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1994                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1995                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1996                            new String[] { Long.class.getName() });
1997    
1998            /**
1999             * Returns all the journal articles where groupId = &#63;.
2000             *
2001             * @param groupId the group ID
2002             * @return the matching journal articles
2003             * @throws SystemException if a system exception occurred
2004             */
2005            @Override
2006            public List<JournalArticle> findByGroupId(long groupId)
2007                    throws SystemException {
2008                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2009            }
2010    
2011            /**
2012             * Returns a range of all the journal articles where groupId = &#63;.
2013             *
2014             * <p>
2015             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2016             * </p>
2017             *
2018             * @param groupId the group ID
2019             * @param start the lower bound of the range of journal articles
2020             * @param end the upper bound of the range of journal articles (not inclusive)
2021             * @return the range of matching journal articles
2022             * @throws SystemException if a system exception occurred
2023             */
2024            @Override
2025            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
2026                    throws SystemException {
2027                    return findByGroupId(groupId, start, end, null);
2028            }
2029    
2030            /**
2031             * Returns an ordered range of all the journal articles where groupId = &#63;.
2032             *
2033             * <p>
2034             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2035             * </p>
2036             *
2037             * @param groupId the group ID
2038             * @param start the lower bound of the range of journal articles
2039             * @param end the upper bound of the range of journal articles (not inclusive)
2040             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2041             * @return the ordered range of matching journal articles
2042             * @throws SystemException if a system exception occurred
2043             */
2044            @Override
2045            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
2046                    OrderByComparator orderByComparator) throws SystemException {
2047                    boolean pagination = true;
2048                    FinderPath finderPath = null;
2049                    Object[] finderArgs = null;
2050    
2051                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2052                                    (orderByComparator == null)) {
2053                            pagination = false;
2054                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2055                            finderArgs = new Object[] { groupId };
2056                    }
2057                    else {
2058                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2059                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2060                    }
2061    
2062                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2063                                    finderArgs, this);
2064    
2065                    if ((list != null) && !list.isEmpty()) {
2066                            for (JournalArticle journalArticle : list) {
2067                                    if ((groupId != journalArticle.getGroupId())) {
2068                                            list = null;
2069    
2070                                            break;
2071                                    }
2072                            }
2073                    }
2074    
2075                    if (list == null) {
2076                            StringBundler query = null;
2077    
2078                            if (orderByComparator != null) {
2079                                    query = new StringBundler(3 +
2080                                                    (orderByComparator.getOrderByFields().length * 3));
2081                            }
2082                            else {
2083                                    query = new StringBundler(3);
2084                            }
2085    
2086                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2087    
2088                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2089    
2090                            if (orderByComparator != null) {
2091                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2092                                            orderByComparator);
2093                            }
2094                            else
2095                             if (pagination) {
2096                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2097                            }
2098    
2099                            String sql = query.toString();
2100    
2101                            Session session = null;
2102    
2103                            try {
2104                                    session = openSession();
2105    
2106                                    Query q = session.createQuery(sql);
2107    
2108                                    QueryPos qPos = QueryPos.getInstance(q);
2109    
2110                                    qPos.add(groupId);
2111    
2112                                    if (!pagination) {
2113                                            list = (List<JournalArticle>)QueryUtil.list(q,
2114                                                            getDialect(), start, end, false);
2115    
2116                                            Collections.sort(list);
2117    
2118                                            list = new UnmodifiableList<JournalArticle>(list);
2119                                    }
2120                                    else {
2121                                            list = (List<JournalArticle>)QueryUtil.list(q,
2122                                                            getDialect(), start, end);
2123                                    }
2124    
2125                                    cacheResult(list);
2126    
2127                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2128                            }
2129                            catch (Exception e) {
2130                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2131    
2132                                    throw processException(e);
2133                            }
2134                            finally {
2135                                    closeSession(session);
2136                            }
2137                    }
2138    
2139                    return list;
2140            }
2141    
2142            /**
2143             * Returns the first journal article in the ordered set where groupId = &#63;.
2144             *
2145             * @param groupId the group ID
2146             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2147             * @return the first matching journal article
2148             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2149             * @throws SystemException if a system exception occurred
2150             */
2151            @Override
2152            public JournalArticle findByGroupId_First(long groupId,
2153                    OrderByComparator orderByComparator)
2154                    throws NoSuchArticleException, SystemException {
2155                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2156                                    orderByComparator);
2157    
2158                    if (journalArticle != null) {
2159                            return journalArticle;
2160                    }
2161    
2162                    StringBundler msg = new StringBundler(4);
2163    
2164                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2165    
2166                    msg.append("groupId=");
2167                    msg.append(groupId);
2168    
2169                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2170    
2171                    throw new NoSuchArticleException(msg.toString());
2172            }
2173    
2174            /**
2175             * Returns the first journal article in the ordered set where groupId = &#63;.
2176             *
2177             * @param groupId the group ID
2178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2179             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2180             * @throws SystemException if a system exception occurred
2181             */
2182            @Override
2183            public JournalArticle fetchByGroupId_First(long groupId,
2184                    OrderByComparator orderByComparator) throws SystemException {
2185                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2186                                    orderByComparator);
2187    
2188                    if (!list.isEmpty()) {
2189                            return list.get(0);
2190                    }
2191    
2192                    return null;
2193            }
2194    
2195            /**
2196             * Returns the last journal article in the ordered set where groupId = &#63;.
2197             *
2198             * @param groupId the group ID
2199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2200             * @return the last matching journal article
2201             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2202             * @throws SystemException if a system exception occurred
2203             */
2204            @Override
2205            public JournalArticle findByGroupId_Last(long groupId,
2206                    OrderByComparator orderByComparator)
2207                    throws NoSuchArticleException, SystemException {
2208                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2209                                    orderByComparator);
2210    
2211                    if (journalArticle != null) {
2212                            return journalArticle;
2213                    }
2214    
2215                    StringBundler msg = new StringBundler(4);
2216    
2217                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2218    
2219                    msg.append("groupId=");
2220                    msg.append(groupId);
2221    
2222                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2223    
2224                    throw new NoSuchArticleException(msg.toString());
2225            }
2226    
2227            /**
2228             * Returns the last journal article in the ordered set where groupId = &#63;.
2229             *
2230             * @param groupId the group ID
2231             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2232             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2233             * @throws SystemException if a system exception occurred
2234             */
2235            @Override
2236            public JournalArticle fetchByGroupId_Last(long groupId,
2237                    OrderByComparator orderByComparator) throws SystemException {
2238                    int count = countByGroupId(groupId);
2239    
2240                    if (count == 0) {
2241                            return null;
2242                    }
2243    
2244                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2245                                    orderByComparator);
2246    
2247                    if (!list.isEmpty()) {
2248                            return list.get(0);
2249                    }
2250    
2251                    return null;
2252            }
2253    
2254            /**
2255             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2256             *
2257             * @param id the primary key of the current journal article
2258             * @param groupId the group ID
2259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2260             * @return the previous, current, and next journal article
2261             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2262             * @throws SystemException if a system exception occurred
2263             */
2264            @Override
2265            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2266                    OrderByComparator orderByComparator)
2267                    throws NoSuchArticleException, SystemException {
2268                    JournalArticle journalArticle = findByPrimaryKey(id);
2269    
2270                    Session session = null;
2271    
2272                    try {
2273                            session = openSession();
2274    
2275                            JournalArticle[] array = new JournalArticleImpl[3];
2276    
2277                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2278                                            groupId, orderByComparator, true);
2279    
2280                            array[1] = journalArticle;
2281    
2282                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2283                                            groupId, orderByComparator, false);
2284    
2285                            return array;
2286                    }
2287                    catch (Exception e) {
2288                            throw processException(e);
2289                    }
2290                    finally {
2291                            closeSession(session);
2292                    }
2293            }
2294    
2295            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2296                    JournalArticle journalArticle, long groupId,
2297                    OrderByComparator orderByComparator, boolean previous) {
2298                    StringBundler query = null;
2299    
2300                    if (orderByComparator != null) {
2301                            query = new StringBundler(6 +
2302                                            (orderByComparator.getOrderByFields().length * 6));
2303                    }
2304                    else {
2305                            query = new StringBundler(3);
2306                    }
2307    
2308                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2309    
2310                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2311    
2312                    if (orderByComparator != null) {
2313                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2314    
2315                            if (orderByConditionFields.length > 0) {
2316                                    query.append(WHERE_AND);
2317                            }
2318    
2319                            for (int i = 0; i < orderByConditionFields.length; i++) {
2320                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2321                                    query.append(orderByConditionFields[i]);
2322    
2323                                    if ((i + 1) < orderByConditionFields.length) {
2324                                            if (orderByComparator.isAscending() ^ previous) {
2325                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2326                                            }
2327                                            else {
2328                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2329                                            }
2330                                    }
2331                                    else {
2332                                            if (orderByComparator.isAscending() ^ previous) {
2333                                                    query.append(WHERE_GREATER_THAN);
2334                                            }
2335                                            else {
2336                                                    query.append(WHERE_LESSER_THAN);
2337                                            }
2338                                    }
2339                            }
2340    
2341                            query.append(ORDER_BY_CLAUSE);
2342    
2343                            String[] orderByFields = orderByComparator.getOrderByFields();
2344    
2345                            for (int i = 0; i < orderByFields.length; i++) {
2346                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2347                                    query.append(orderByFields[i]);
2348    
2349                                    if ((i + 1) < orderByFields.length) {
2350                                            if (orderByComparator.isAscending() ^ previous) {
2351                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2352                                            }
2353                                            else {
2354                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2355                                            }
2356                                    }
2357                                    else {
2358                                            if (orderByComparator.isAscending() ^ previous) {
2359                                                    query.append(ORDER_BY_ASC);
2360                                            }
2361                                            else {
2362                                                    query.append(ORDER_BY_DESC);
2363                                            }
2364                                    }
2365                            }
2366                    }
2367                    else {
2368                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2369                    }
2370    
2371                    String sql = query.toString();
2372    
2373                    Query q = session.createQuery(sql);
2374    
2375                    q.setFirstResult(0);
2376                    q.setMaxResults(2);
2377    
2378                    QueryPos qPos = QueryPos.getInstance(q);
2379    
2380                    qPos.add(groupId);
2381    
2382                    if (orderByComparator != null) {
2383                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2384    
2385                            for (Object value : values) {
2386                                    qPos.add(value);
2387                            }
2388                    }
2389    
2390                    List<JournalArticle> list = q.list();
2391    
2392                    if (list.size() == 2) {
2393                            return list.get(1);
2394                    }
2395                    else {
2396                            return null;
2397                    }
2398            }
2399    
2400            /**
2401             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2402             *
2403             * @param groupId the group ID
2404             * @return the matching journal articles that the user has permission to view
2405             * @throws SystemException if a system exception occurred
2406             */
2407            @Override
2408            public List<JournalArticle> filterFindByGroupId(long groupId)
2409                    throws SystemException {
2410                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2411                            QueryUtil.ALL_POS, null);
2412            }
2413    
2414            /**
2415             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2416             *
2417             * <p>
2418             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2419             * </p>
2420             *
2421             * @param groupId the group ID
2422             * @param start the lower bound of the range of journal articles
2423             * @param end the upper bound of the range of journal articles (not inclusive)
2424             * @return the range of matching journal articles that the user has permission to view
2425             * @throws SystemException if a system exception occurred
2426             */
2427            @Override
2428            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2429                    int end) throws SystemException {
2430                    return filterFindByGroupId(groupId, start, end, null);
2431            }
2432    
2433            /**
2434             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2435             *
2436             * <p>
2437             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2438             * </p>
2439             *
2440             * @param groupId the group ID
2441             * @param start the lower bound of the range of journal articles
2442             * @param end the upper bound of the range of journal articles (not inclusive)
2443             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2444             * @return the ordered range of matching journal articles that the user has permission to view
2445             * @throws SystemException if a system exception occurred
2446             */
2447            @Override
2448            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2449                    int end, OrderByComparator orderByComparator) throws SystemException {
2450                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2451                            return findByGroupId(groupId, start, end, orderByComparator);
2452                    }
2453    
2454                    StringBundler query = null;
2455    
2456                    if (orderByComparator != null) {
2457                            query = new StringBundler(3 +
2458                                            (orderByComparator.getOrderByFields().length * 3));
2459                    }
2460                    else {
2461                            query = new StringBundler(3);
2462                    }
2463    
2464                    if (getDB().isSupportsInlineDistinct()) {
2465                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2466                    }
2467                    else {
2468                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2469                    }
2470    
2471                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2472    
2473                    if (!getDB().isSupportsInlineDistinct()) {
2474                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2475                    }
2476    
2477                    if (orderByComparator != null) {
2478                            if (getDB().isSupportsInlineDistinct()) {
2479                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2480                                            orderByComparator, true);
2481                            }
2482                            else {
2483                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2484                                            orderByComparator, true);
2485                            }
2486                    }
2487                    else {
2488                            if (getDB().isSupportsInlineDistinct()) {
2489                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2490                            }
2491                            else {
2492                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2493                            }
2494                    }
2495    
2496                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2497                                    JournalArticle.class.getName(),
2498                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2499    
2500                    Session session = null;
2501    
2502                    try {
2503                            session = openSession();
2504    
2505                            SQLQuery q = session.createSQLQuery(sql);
2506    
2507                            if (getDB().isSupportsInlineDistinct()) {
2508                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2509                            }
2510                            else {
2511                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2512                            }
2513    
2514                            QueryPos qPos = QueryPos.getInstance(q);
2515    
2516                            qPos.add(groupId);
2517    
2518                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2519                                    end);
2520                    }
2521                    catch (Exception e) {
2522                            throw processException(e);
2523                    }
2524                    finally {
2525                            closeSession(session);
2526                    }
2527            }
2528    
2529            /**
2530             * 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;.
2531             *
2532             * @param id the primary key of the current journal article
2533             * @param groupId the group ID
2534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2535             * @return the previous, current, and next journal article
2536             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2537             * @throws SystemException if a system exception occurred
2538             */
2539            @Override
2540            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2541                    long groupId, OrderByComparator orderByComparator)
2542                    throws NoSuchArticleException, SystemException {
2543                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2544                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2545                    }
2546    
2547                    JournalArticle journalArticle = findByPrimaryKey(id);
2548    
2549                    Session session = null;
2550    
2551                    try {
2552                            session = openSession();
2553    
2554                            JournalArticle[] array = new JournalArticleImpl[3];
2555    
2556                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2557                                            groupId, orderByComparator, true);
2558    
2559                            array[1] = journalArticle;
2560    
2561                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2562                                            groupId, orderByComparator, false);
2563    
2564                            return array;
2565                    }
2566                    catch (Exception e) {
2567                            throw processException(e);
2568                    }
2569                    finally {
2570                            closeSession(session);
2571                    }
2572            }
2573    
2574            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2575                    JournalArticle journalArticle, long groupId,
2576                    OrderByComparator orderByComparator, boolean previous) {
2577                    StringBundler query = null;
2578    
2579                    if (orderByComparator != null) {
2580                            query = new StringBundler(6 +
2581                                            (orderByComparator.getOrderByFields().length * 6));
2582                    }
2583                    else {
2584                            query = new StringBundler(3);
2585                    }
2586    
2587                    if (getDB().isSupportsInlineDistinct()) {
2588                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2589                    }
2590                    else {
2591                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2592                    }
2593    
2594                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2595    
2596                    if (!getDB().isSupportsInlineDistinct()) {
2597                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2598                    }
2599    
2600                    if (orderByComparator != null) {
2601                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2602    
2603                            if (orderByConditionFields.length > 0) {
2604                                    query.append(WHERE_AND);
2605                            }
2606    
2607                            for (int i = 0; i < orderByConditionFields.length; i++) {
2608                                    if (getDB().isSupportsInlineDistinct()) {
2609                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2610                                    }
2611                                    else {
2612                                            query.append(_ORDER_BY_ENTITY_TABLE);
2613                                    }
2614    
2615                                    query.append(orderByConditionFields[i]);
2616    
2617                                    if ((i + 1) < orderByConditionFields.length) {
2618                                            if (orderByComparator.isAscending() ^ previous) {
2619                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2620                                            }
2621                                            else {
2622                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2623                                            }
2624                                    }
2625                                    else {
2626                                            if (orderByComparator.isAscending() ^ previous) {
2627                                                    query.append(WHERE_GREATER_THAN);
2628                                            }
2629                                            else {
2630                                                    query.append(WHERE_LESSER_THAN);
2631                                            }
2632                                    }
2633                            }
2634    
2635                            query.append(ORDER_BY_CLAUSE);
2636    
2637                            String[] orderByFields = orderByComparator.getOrderByFields();
2638    
2639                            for (int i = 0; i < orderByFields.length; i++) {
2640                                    if (getDB().isSupportsInlineDistinct()) {
2641                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2642                                    }
2643                                    else {
2644                                            query.append(_ORDER_BY_ENTITY_TABLE);
2645                                    }
2646    
2647                                    query.append(orderByFields[i]);
2648    
2649                                    if ((i + 1) < orderByFields.length) {
2650                                            if (orderByComparator.isAscending() ^ previous) {
2651                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2652                                            }
2653                                            else {
2654                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2655                                            }
2656                                    }
2657                                    else {
2658                                            if (orderByComparator.isAscending() ^ previous) {
2659                                                    query.append(ORDER_BY_ASC);
2660                                            }
2661                                            else {
2662                                                    query.append(ORDER_BY_DESC);
2663                                            }
2664                                    }
2665                            }
2666                    }
2667                    else {
2668                            if (getDB().isSupportsInlineDistinct()) {
2669                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2670                            }
2671                            else {
2672                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2673                            }
2674                    }
2675    
2676                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2677                                    JournalArticle.class.getName(),
2678                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2679    
2680                    SQLQuery q = session.createSQLQuery(sql);
2681    
2682                    q.setFirstResult(0);
2683                    q.setMaxResults(2);
2684    
2685                    if (getDB().isSupportsInlineDistinct()) {
2686                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2687                    }
2688                    else {
2689                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2690                    }
2691    
2692                    QueryPos qPos = QueryPos.getInstance(q);
2693    
2694                    qPos.add(groupId);
2695    
2696                    if (orderByComparator != null) {
2697                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2698    
2699                            for (Object value : values) {
2700                                    qPos.add(value);
2701                            }
2702                    }
2703    
2704                    List<JournalArticle> list = q.list();
2705    
2706                    if (list.size() == 2) {
2707                            return list.get(1);
2708                    }
2709                    else {
2710                            return null;
2711                    }
2712            }
2713    
2714            /**
2715             * Removes all the journal articles where groupId = &#63; from the database.
2716             *
2717             * @param groupId the group ID
2718             * @throws SystemException if a system exception occurred
2719             */
2720            @Override
2721            public void removeByGroupId(long groupId) throws SystemException {
2722                    for (JournalArticle journalArticle : findByGroupId(groupId,
2723                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2724                            remove(journalArticle);
2725                    }
2726            }
2727    
2728            /**
2729             * Returns the number of journal articles where groupId = &#63;.
2730             *
2731             * @param groupId the group ID
2732             * @return the number of matching journal articles
2733             * @throws SystemException if a system exception occurred
2734             */
2735            @Override
2736            public int countByGroupId(long groupId) throws SystemException {
2737                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2738    
2739                    Object[] finderArgs = new Object[] { groupId };
2740    
2741                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2742                                    this);
2743    
2744                    if (count == null) {
2745                            StringBundler query = new StringBundler(2);
2746    
2747                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2748    
2749                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2750    
2751                            String sql = query.toString();
2752    
2753                            Session session = null;
2754    
2755                            try {
2756                                    session = openSession();
2757    
2758                                    Query q = session.createQuery(sql);
2759    
2760                                    QueryPos qPos = QueryPos.getInstance(q);
2761    
2762                                    qPos.add(groupId);
2763    
2764                                    count = (Long)q.uniqueResult();
2765    
2766                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2767                            }
2768                            catch (Exception e) {
2769                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2770    
2771                                    throw processException(e);
2772                            }
2773                            finally {
2774                                    closeSession(session);
2775                            }
2776                    }
2777    
2778                    return count.intValue();
2779            }
2780    
2781            /**
2782             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2783             *
2784             * @param groupId the group ID
2785             * @return the number of matching journal articles that the user has permission to view
2786             * @throws SystemException if a system exception occurred
2787             */
2788            @Override
2789            public int filterCountByGroupId(long groupId) throws SystemException {
2790                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2791                            return countByGroupId(groupId);
2792                    }
2793    
2794                    StringBundler query = new StringBundler(2);
2795    
2796                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2797    
2798                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2799    
2800                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2801                                    JournalArticle.class.getName(),
2802                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2803    
2804                    Session session = null;
2805    
2806                    try {
2807                            session = openSession();
2808    
2809                            SQLQuery q = session.createSQLQuery(sql);
2810    
2811                            q.addScalar(COUNT_COLUMN_NAME,
2812                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2813    
2814                            QueryPos qPos = QueryPos.getInstance(q);
2815    
2816                            qPos.add(groupId);
2817    
2818                            Long count = (Long)q.uniqueResult();
2819    
2820                            return count.intValue();
2821                    }
2822                    catch (Exception e) {
2823                            throw processException(e);
2824                    }
2825                    finally {
2826                            closeSession(session);
2827                    }
2828            }
2829    
2830            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2831            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2832                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2833                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2834                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2835                            "findByCompanyId",
2836                            new String[] {
2837                                    Long.class.getName(),
2838                                    
2839                            Integer.class.getName(), Integer.class.getName(),
2840                                    OrderByComparator.class.getName()
2841                            });
2842            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2843                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2844                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2845                            JournalArticleImpl.class,
2846                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2847                            new String[] { Long.class.getName() },
2848                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2849                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2850                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2851            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2852                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2853                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2854                            new String[] { Long.class.getName() });
2855    
2856            /**
2857             * Returns all the journal articles where companyId = &#63;.
2858             *
2859             * @param companyId the company ID
2860             * @return the matching journal articles
2861             * @throws SystemException if a system exception occurred
2862             */
2863            @Override
2864            public List<JournalArticle> findByCompanyId(long companyId)
2865                    throws SystemException {
2866                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2867                            null);
2868            }
2869    
2870            /**
2871             * Returns a range of all the journal articles where companyId = &#63;.
2872             *
2873             * <p>
2874             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2875             * </p>
2876             *
2877             * @param companyId the company ID
2878             * @param start the lower bound of the range of journal articles
2879             * @param end the upper bound of the range of journal articles (not inclusive)
2880             * @return the range of matching journal articles
2881             * @throws SystemException if a system exception occurred
2882             */
2883            @Override
2884            public List<JournalArticle> findByCompanyId(long companyId, int start,
2885                    int end) throws SystemException {
2886                    return findByCompanyId(companyId, start, end, null);
2887            }
2888    
2889            /**
2890             * Returns an ordered range of all the journal articles where companyId = &#63;.
2891             *
2892             * <p>
2893             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2894             * </p>
2895             *
2896             * @param companyId the company ID
2897             * @param start the lower bound of the range of journal articles
2898             * @param end the upper bound of the range of journal articles (not inclusive)
2899             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2900             * @return the ordered range of matching journal articles
2901             * @throws SystemException if a system exception occurred
2902             */
2903            @Override
2904            public List<JournalArticle> findByCompanyId(long companyId, int start,
2905                    int end, OrderByComparator orderByComparator) throws SystemException {
2906                    boolean pagination = true;
2907                    FinderPath finderPath = null;
2908                    Object[] finderArgs = null;
2909    
2910                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2911                                    (orderByComparator == null)) {
2912                            pagination = false;
2913                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2914                            finderArgs = new Object[] { companyId };
2915                    }
2916                    else {
2917                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2918                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2919                    }
2920    
2921                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2922                                    finderArgs, this);
2923    
2924                    if ((list != null) && !list.isEmpty()) {
2925                            for (JournalArticle journalArticle : list) {
2926                                    if ((companyId != journalArticle.getCompanyId())) {
2927                                            list = null;
2928    
2929                                            break;
2930                                    }
2931                            }
2932                    }
2933    
2934                    if (list == null) {
2935                            StringBundler query = null;
2936    
2937                            if (orderByComparator != null) {
2938                                    query = new StringBundler(3 +
2939                                                    (orderByComparator.getOrderByFields().length * 3));
2940                            }
2941                            else {
2942                                    query = new StringBundler(3);
2943                            }
2944    
2945                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2946    
2947                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2948    
2949                            if (orderByComparator != null) {
2950                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2951                                            orderByComparator);
2952                            }
2953                            else
2954                             if (pagination) {
2955                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2956                            }
2957    
2958                            String sql = query.toString();
2959    
2960                            Session session = null;
2961    
2962                            try {
2963                                    session = openSession();
2964    
2965                                    Query q = session.createQuery(sql);
2966    
2967                                    QueryPos qPos = QueryPos.getInstance(q);
2968    
2969                                    qPos.add(companyId);
2970    
2971                                    if (!pagination) {
2972                                            list = (List<JournalArticle>)QueryUtil.list(q,
2973                                                            getDialect(), start, end, false);
2974    
2975                                            Collections.sort(list);
2976    
2977                                            list = new UnmodifiableList<JournalArticle>(list);
2978                                    }
2979                                    else {
2980                                            list = (List<JournalArticle>)QueryUtil.list(q,
2981                                                            getDialect(), start, end);
2982                                    }
2983    
2984                                    cacheResult(list);
2985    
2986                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2987                            }
2988                            catch (Exception e) {
2989                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2990    
2991                                    throw processException(e);
2992                            }
2993                            finally {
2994                                    closeSession(session);
2995                            }
2996                    }
2997    
2998                    return list;
2999            }
3000    
3001            /**
3002             * Returns the first journal article in the ordered set where companyId = &#63;.
3003             *
3004             * @param companyId the company ID
3005             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3006             * @return the first matching journal article
3007             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3008             * @throws SystemException if a system exception occurred
3009             */
3010            @Override
3011            public JournalArticle findByCompanyId_First(long companyId,
3012                    OrderByComparator orderByComparator)
3013                    throws NoSuchArticleException, SystemException {
3014                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
3015                                    orderByComparator);
3016    
3017                    if (journalArticle != null) {
3018                            return journalArticle;
3019                    }
3020    
3021                    StringBundler msg = new StringBundler(4);
3022    
3023                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3024    
3025                    msg.append("companyId=");
3026                    msg.append(companyId);
3027    
3028                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3029    
3030                    throw new NoSuchArticleException(msg.toString());
3031            }
3032    
3033            /**
3034             * Returns the first journal article in the ordered set where companyId = &#63;.
3035             *
3036             * @param companyId the company ID
3037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3038             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3039             * @throws SystemException if a system exception occurred
3040             */
3041            @Override
3042            public JournalArticle fetchByCompanyId_First(long companyId,
3043                    OrderByComparator orderByComparator) throws SystemException {
3044                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
3045                                    orderByComparator);
3046    
3047                    if (!list.isEmpty()) {
3048                            return list.get(0);
3049                    }
3050    
3051                    return null;
3052            }
3053    
3054            /**
3055             * Returns the last journal article in the ordered set where companyId = &#63;.
3056             *
3057             * @param companyId the company ID
3058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3059             * @return the last matching journal article
3060             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3061             * @throws SystemException if a system exception occurred
3062             */
3063            @Override
3064            public JournalArticle findByCompanyId_Last(long companyId,
3065                    OrderByComparator orderByComparator)
3066                    throws NoSuchArticleException, SystemException {
3067                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
3068                                    orderByComparator);
3069    
3070                    if (journalArticle != null) {
3071                            return journalArticle;
3072                    }
3073    
3074                    StringBundler msg = new StringBundler(4);
3075    
3076                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3077    
3078                    msg.append("companyId=");
3079                    msg.append(companyId);
3080    
3081                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3082    
3083                    throw new NoSuchArticleException(msg.toString());
3084            }
3085    
3086            /**
3087             * Returns the last journal article in the ordered set where companyId = &#63;.
3088             *
3089             * @param companyId the company ID
3090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3091             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3092             * @throws SystemException if a system exception occurred
3093             */
3094            @Override
3095            public JournalArticle fetchByCompanyId_Last(long companyId,
3096                    OrderByComparator orderByComparator) throws SystemException {
3097                    int count = countByCompanyId(companyId);
3098    
3099                    if (count == 0) {
3100                            return null;
3101                    }
3102    
3103                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3104                                    count, orderByComparator);
3105    
3106                    if (!list.isEmpty()) {
3107                            return list.get(0);
3108                    }
3109    
3110                    return null;
3111            }
3112    
3113            /**
3114             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3115             *
3116             * @param id the primary key of the current journal article
3117             * @param companyId the company ID
3118             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3119             * @return the previous, current, and next journal article
3120             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3121             * @throws SystemException if a system exception occurred
3122             */
3123            @Override
3124            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3125                    long companyId, OrderByComparator orderByComparator)
3126                    throws NoSuchArticleException, SystemException {
3127                    JournalArticle journalArticle = findByPrimaryKey(id);
3128    
3129                    Session session = null;
3130    
3131                    try {
3132                            session = openSession();
3133    
3134                            JournalArticle[] array = new JournalArticleImpl[3];
3135    
3136                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3137                                            companyId, orderByComparator, true);
3138    
3139                            array[1] = journalArticle;
3140    
3141                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3142                                            companyId, orderByComparator, false);
3143    
3144                            return array;
3145                    }
3146                    catch (Exception e) {
3147                            throw processException(e);
3148                    }
3149                    finally {
3150                            closeSession(session);
3151                    }
3152            }
3153    
3154            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3155                    JournalArticle journalArticle, long companyId,
3156                    OrderByComparator orderByComparator, boolean previous) {
3157                    StringBundler query = null;
3158    
3159                    if (orderByComparator != null) {
3160                            query = new StringBundler(6 +
3161                                            (orderByComparator.getOrderByFields().length * 6));
3162                    }
3163                    else {
3164                            query = new StringBundler(3);
3165                    }
3166    
3167                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3168    
3169                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3170    
3171                    if (orderByComparator != null) {
3172                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3173    
3174                            if (orderByConditionFields.length > 0) {
3175                                    query.append(WHERE_AND);
3176                            }
3177    
3178                            for (int i = 0; i < orderByConditionFields.length; i++) {
3179                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3180                                    query.append(orderByConditionFields[i]);
3181    
3182                                    if ((i + 1) < orderByConditionFields.length) {
3183                                            if (orderByComparator.isAscending() ^ previous) {
3184                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3185                                            }
3186                                            else {
3187                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3188                                            }
3189                                    }
3190                                    else {
3191                                            if (orderByComparator.isAscending() ^ previous) {
3192                                                    query.append(WHERE_GREATER_THAN);
3193                                            }
3194                                            else {
3195                                                    query.append(WHERE_LESSER_THAN);
3196                                            }
3197                                    }
3198                            }
3199    
3200                            query.append(ORDER_BY_CLAUSE);
3201    
3202                            String[] orderByFields = orderByComparator.getOrderByFields();
3203    
3204                            for (int i = 0; i < orderByFields.length; i++) {
3205                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3206                                    query.append(orderByFields[i]);
3207    
3208                                    if ((i + 1) < orderByFields.length) {
3209                                            if (orderByComparator.isAscending() ^ previous) {
3210                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3211                                            }
3212                                            else {
3213                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3214                                            }
3215                                    }
3216                                    else {
3217                                            if (orderByComparator.isAscending() ^ previous) {
3218                                                    query.append(ORDER_BY_ASC);
3219                                            }
3220                                            else {
3221                                                    query.append(ORDER_BY_DESC);
3222                                            }
3223                                    }
3224                            }
3225                    }
3226                    else {
3227                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3228                    }
3229    
3230                    String sql = query.toString();
3231    
3232                    Query q = session.createQuery(sql);
3233    
3234                    q.setFirstResult(0);
3235                    q.setMaxResults(2);
3236    
3237                    QueryPos qPos = QueryPos.getInstance(q);
3238    
3239                    qPos.add(companyId);
3240    
3241                    if (orderByComparator != null) {
3242                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3243    
3244                            for (Object value : values) {
3245                                    qPos.add(value);
3246                            }
3247                    }
3248    
3249                    List<JournalArticle> list = q.list();
3250    
3251                    if (list.size() == 2) {
3252                            return list.get(1);
3253                    }
3254                    else {
3255                            return null;
3256                    }
3257            }
3258    
3259            /**
3260             * Removes all the journal articles where companyId = &#63; from the database.
3261             *
3262             * @param companyId the company ID
3263             * @throws SystemException if a system exception occurred
3264             */
3265            @Override
3266            public void removeByCompanyId(long companyId) throws SystemException {
3267                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3268                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3269                            remove(journalArticle);
3270                    }
3271            }
3272    
3273            /**
3274             * Returns the number of journal articles where companyId = &#63;.
3275             *
3276             * @param companyId the company ID
3277             * @return the number of matching journal articles
3278             * @throws SystemException if a system exception occurred
3279             */
3280            @Override
3281            public int countByCompanyId(long companyId) throws SystemException {
3282                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3283    
3284                    Object[] finderArgs = new Object[] { companyId };
3285    
3286                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3287                                    this);
3288    
3289                    if (count == null) {
3290                            StringBundler query = new StringBundler(2);
3291    
3292                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3293    
3294                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3295    
3296                            String sql = query.toString();
3297    
3298                            Session session = null;
3299    
3300                            try {
3301                                    session = openSession();
3302    
3303                                    Query q = session.createQuery(sql);
3304    
3305                                    QueryPos qPos = QueryPos.getInstance(q);
3306    
3307                                    qPos.add(companyId);
3308    
3309                                    count = (Long)q.uniqueResult();
3310    
3311                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3312                            }
3313                            catch (Exception e) {
3314                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3315    
3316                                    throw processException(e);
3317                            }
3318                            finally {
3319                                    closeSession(session);
3320                            }
3321                    }
3322    
3323                    return count.intValue();
3324            }
3325    
3326            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3327            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
3328                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3329                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3330                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3331                            "findByStructureId",
3332                            new String[] {
3333                                    String.class.getName(),
3334                                    
3335                            Integer.class.getName(), Integer.class.getName(),
3336                                    OrderByComparator.class.getName()
3337                            });
3338            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
3339                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3340                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3341                            JournalArticleImpl.class,
3342                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
3343                            new String[] { String.class.getName() },
3344                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
3345                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3346                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3347            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3348                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3349                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
3350                            new String[] { String.class.getName() });
3351            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID =
3352                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3353                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3354                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByStructureId",
3355                            new String[] { String.class.getName() });
3356    
3357            /**
3358             * Returns all the journal articles where structureId = &#63;.
3359             *
3360             * @param structureId the structure ID
3361             * @return the matching journal articles
3362             * @throws SystemException if a system exception occurred
3363             */
3364            @Override
3365            public List<JournalArticle> findByStructureId(String structureId)
3366                    throws SystemException {
3367                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3368                            QueryUtil.ALL_POS, null);
3369            }
3370    
3371            /**
3372             * Returns a range of all the journal articles where structureId = &#63;.
3373             *
3374             * <p>
3375             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3376             * </p>
3377             *
3378             * @param structureId the structure ID
3379             * @param start the lower bound of the range of journal articles
3380             * @param end the upper bound of the range of journal articles (not inclusive)
3381             * @return the range of matching journal articles
3382             * @throws SystemException if a system exception occurred
3383             */
3384            @Override
3385            public List<JournalArticle> findByStructureId(String structureId,
3386                    int start, int end) throws SystemException {
3387                    return findByStructureId(structureId, start, end, null);
3388            }
3389    
3390            /**
3391             * Returns an ordered range of all the journal articles where structureId = &#63;.
3392             *
3393             * <p>
3394             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3395             * </p>
3396             *
3397             * @param structureId the structure ID
3398             * @param start the lower bound of the range of journal articles
3399             * @param end the upper bound of the range of journal articles (not inclusive)
3400             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3401             * @return the ordered range of matching journal articles
3402             * @throws SystemException if a system exception occurred
3403             */
3404            @Override
3405            public List<JournalArticle> findByStructureId(String structureId,
3406                    int start, int end, OrderByComparator orderByComparator)
3407                    throws SystemException {
3408                    boolean pagination = true;
3409                    FinderPath finderPath = null;
3410                    Object[] finderArgs = null;
3411    
3412                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3413                                    (orderByComparator == null)) {
3414                            pagination = false;
3415                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3416                            finderArgs = new Object[] { structureId };
3417                    }
3418                    else {
3419                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3420                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3421                    }
3422    
3423                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3424                                    finderArgs, this);
3425    
3426                    if ((list != null) && !list.isEmpty()) {
3427                            for (JournalArticle journalArticle : list) {
3428                                    if (!Validator.equals(structureId,
3429                                                            journalArticle.getStructureId())) {
3430                                            list = null;
3431    
3432                                            break;
3433                                    }
3434                            }
3435                    }
3436    
3437                    if (list == null) {
3438                            StringBundler query = null;
3439    
3440                            if (orderByComparator != null) {
3441                                    query = new StringBundler(3 +
3442                                                    (orderByComparator.getOrderByFields().length * 3));
3443                            }
3444                            else {
3445                                    query = new StringBundler(3);
3446                            }
3447    
3448                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3449    
3450                            boolean bindStructureId = false;
3451    
3452                            if (structureId == null) {
3453                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3454                            }
3455                            else if (structureId.equals(StringPool.BLANK)) {
3456                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3457                            }
3458                            else {
3459                                    bindStructureId = true;
3460    
3461                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3462                            }
3463    
3464                            if (orderByComparator != null) {
3465                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3466                                            orderByComparator);
3467                            }
3468                            else
3469                             if (pagination) {
3470                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3471                            }
3472    
3473                            String sql = query.toString();
3474    
3475                            Session session = null;
3476    
3477                            try {
3478                                    session = openSession();
3479    
3480                                    Query q = session.createQuery(sql);
3481    
3482                                    QueryPos qPos = QueryPos.getInstance(q);
3483    
3484                                    if (bindStructureId) {
3485                                            qPos.add(structureId);
3486                                    }
3487    
3488                                    if (!pagination) {
3489                                            list = (List<JournalArticle>)QueryUtil.list(q,
3490                                                            getDialect(), start, end, false);
3491    
3492                                            Collections.sort(list);
3493    
3494                                            list = new UnmodifiableList<JournalArticle>(list);
3495                                    }
3496                                    else {
3497                                            list = (List<JournalArticle>)QueryUtil.list(q,
3498                                                            getDialect(), start, end);
3499                                    }
3500    
3501                                    cacheResult(list);
3502    
3503                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3504                            }
3505                            catch (Exception e) {
3506                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3507    
3508                                    throw processException(e);
3509                            }
3510                            finally {
3511                                    closeSession(session);
3512                            }
3513                    }
3514    
3515                    return list;
3516            }
3517    
3518            /**
3519             * Returns the first journal article in the ordered set where structureId = &#63;.
3520             *
3521             * @param structureId the structure ID
3522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3523             * @return the first matching journal article
3524             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3525             * @throws SystemException if a system exception occurred
3526             */
3527            @Override
3528            public JournalArticle findByStructureId_First(String structureId,
3529                    OrderByComparator orderByComparator)
3530                    throws NoSuchArticleException, SystemException {
3531                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3532                                    orderByComparator);
3533    
3534                    if (journalArticle != null) {
3535                            return journalArticle;
3536                    }
3537    
3538                    StringBundler msg = new StringBundler(4);
3539    
3540                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3541    
3542                    msg.append("structureId=");
3543                    msg.append(structureId);
3544    
3545                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3546    
3547                    throw new NoSuchArticleException(msg.toString());
3548            }
3549    
3550            /**
3551             * Returns the first journal article in the ordered set where structureId = &#63;.
3552             *
3553             * @param structureId the structure ID
3554             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3555             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3556             * @throws SystemException if a system exception occurred
3557             */
3558            @Override
3559            public JournalArticle fetchByStructureId_First(String structureId,
3560                    OrderByComparator orderByComparator) throws SystemException {
3561                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3562                                    orderByComparator);
3563    
3564                    if (!list.isEmpty()) {
3565                            return list.get(0);
3566                    }
3567    
3568                    return null;
3569            }
3570    
3571            /**
3572             * Returns the last journal article in the ordered set where structureId = &#63;.
3573             *
3574             * @param structureId the structure ID
3575             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3576             * @return the last matching journal article
3577             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3578             * @throws SystemException if a system exception occurred
3579             */
3580            @Override
3581            public JournalArticle findByStructureId_Last(String structureId,
3582                    OrderByComparator orderByComparator)
3583                    throws NoSuchArticleException, SystemException {
3584                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3585                                    orderByComparator);
3586    
3587                    if (journalArticle != null) {
3588                            return journalArticle;
3589                    }
3590    
3591                    StringBundler msg = new StringBundler(4);
3592    
3593                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3594    
3595                    msg.append("structureId=");
3596                    msg.append(structureId);
3597    
3598                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3599    
3600                    throw new NoSuchArticleException(msg.toString());
3601            }
3602    
3603            /**
3604             * Returns the last journal article in the ordered set where structureId = &#63;.
3605             *
3606             * @param structureId the structure ID
3607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3608             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3609             * @throws SystemException if a system exception occurred
3610             */
3611            @Override
3612            public JournalArticle fetchByStructureId_Last(String structureId,
3613                    OrderByComparator orderByComparator) throws SystemException {
3614                    int count = countByStructureId(structureId);
3615    
3616                    if (count == 0) {
3617                            return null;
3618                    }
3619    
3620                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3621                                    count, orderByComparator);
3622    
3623                    if (!list.isEmpty()) {
3624                            return list.get(0);
3625                    }
3626    
3627                    return null;
3628            }
3629    
3630            /**
3631             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3632             *
3633             * @param id the primary key of the current journal article
3634             * @param structureId the structure ID
3635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3636             * @return the previous, current, and next journal article
3637             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3638             * @throws SystemException if a system exception occurred
3639             */
3640            @Override
3641            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3642                    String structureId, OrderByComparator orderByComparator)
3643                    throws NoSuchArticleException, SystemException {
3644                    JournalArticle journalArticle = findByPrimaryKey(id);
3645    
3646                    Session session = null;
3647    
3648                    try {
3649                            session = openSession();
3650    
3651                            JournalArticle[] array = new JournalArticleImpl[3];
3652    
3653                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3654                                            structureId, orderByComparator, true);
3655    
3656                            array[1] = journalArticle;
3657    
3658                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3659                                            structureId, orderByComparator, false);
3660    
3661                            return array;
3662                    }
3663                    catch (Exception e) {
3664                            throw processException(e);
3665                    }
3666                    finally {
3667                            closeSession(session);
3668                    }
3669            }
3670    
3671            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3672                    JournalArticle journalArticle, String structureId,
3673                    OrderByComparator orderByComparator, boolean previous) {
3674                    StringBundler query = null;
3675    
3676                    if (orderByComparator != null) {
3677                            query = new StringBundler(6 +
3678                                            (orderByComparator.getOrderByFields().length * 6));
3679                    }
3680                    else {
3681                            query = new StringBundler(3);
3682                    }
3683    
3684                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3685    
3686                    boolean bindStructureId = false;
3687    
3688                    if (structureId == null) {
3689                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3690                    }
3691                    else if (structureId.equals(StringPool.BLANK)) {
3692                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3693                    }
3694                    else {
3695                            bindStructureId = true;
3696    
3697                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3698                    }
3699    
3700                    if (orderByComparator != null) {
3701                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3702    
3703                            if (orderByConditionFields.length > 0) {
3704                                    query.append(WHERE_AND);
3705                            }
3706    
3707                            for (int i = 0; i < orderByConditionFields.length; i++) {
3708                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3709                                    query.append(orderByConditionFields[i]);
3710    
3711                                    if ((i + 1) < orderByConditionFields.length) {
3712                                            if (orderByComparator.isAscending() ^ previous) {
3713                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3714                                            }
3715                                            else {
3716                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3717                                            }
3718                                    }
3719                                    else {
3720                                            if (orderByComparator.isAscending() ^ previous) {
3721                                                    query.append(WHERE_GREATER_THAN);
3722                                            }
3723                                            else {
3724                                                    query.append(WHERE_LESSER_THAN);
3725                                            }
3726                                    }
3727                            }
3728    
3729                            query.append(ORDER_BY_CLAUSE);
3730    
3731                            String[] orderByFields = orderByComparator.getOrderByFields();
3732    
3733                            for (int i = 0; i < orderByFields.length; i++) {
3734                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3735                                    query.append(orderByFields[i]);
3736    
3737                                    if ((i + 1) < orderByFields.length) {
3738                                            if (orderByComparator.isAscending() ^ previous) {
3739                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3740                                            }
3741                                            else {
3742                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3743                                            }
3744                                    }
3745                                    else {
3746                                            if (orderByComparator.isAscending() ^ previous) {
3747                                                    query.append(ORDER_BY_ASC);
3748                                            }
3749                                            else {
3750                                                    query.append(ORDER_BY_DESC);
3751                                            }
3752                                    }
3753                            }
3754                    }
3755                    else {
3756                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3757                    }
3758    
3759                    String sql = query.toString();
3760    
3761                    Query q = session.createQuery(sql);
3762    
3763                    q.setFirstResult(0);
3764                    q.setMaxResults(2);
3765    
3766                    QueryPos qPos = QueryPos.getInstance(q);
3767    
3768                    if (bindStructureId) {
3769                            qPos.add(structureId);
3770                    }
3771    
3772                    if (orderByComparator != null) {
3773                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3774    
3775                            for (Object value : values) {
3776                                    qPos.add(value);
3777                            }
3778                    }
3779    
3780                    List<JournalArticle> list = q.list();
3781    
3782                    if (list.size() == 2) {
3783                            return list.get(1);
3784                    }
3785                    else {
3786                            return null;
3787                    }
3788            }
3789    
3790            /**
3791             * Returns all the journal articles where structureId = any &#63;.
3792             *
3793             * <p>
3794             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3795             * </p>
3796             *
3797             * @param structureIds the structure IDs
3798             * @return the matching journal articles
3799             * @throws SystemException if a system exception occurred
3800             */
3801            @Override
3802            public List<JournalArticle> findByStructureId(String[] structureIds)
3803                    throws SystemException {
3804                    return findByStructureId(structureIds, QueryUtil.ALL_POS,
3805                            QueryUtil.ALL_POS, null);
3806            }
3807    
3808            /**
3809             * Returns a range of all the journal articles where structureId = any &#63;.
3810             *
3811             * <p>
3812             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3813             * </p>
3814             *
3815             * @param structureIds the structure IDs
3816             * @param start the lower bound of the range of journal articles
3817             * @param end the upper bound of the range of journal articles (not inclusive)
3818             * @return the range of matching journal articles
3819             * @throws SystemException if a system exception occurred
3820             */
3821            @Override
3822            public List<JournalArticle> findByStructureId(String[] structureIds,
3823                    int start, int end) throws SystemException {
3824                    return findByStructureId(structureIds, start, end, null);
3825            }
3826    
3827            /**
3828             * Returns an ordered range of all the journal articles where structureId = any &#63;.
3829             *
3830             * <p>
3831             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3832             * </p>
3833             *
3834             * @param structureIds the structure IDs
3835             * @param start the lower bound of the range of journal articles
3836             * @param end the upper bound of the range of journal articles (not inclusive)
3837             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3838             * @return the ordered range of matching journal articles
3839             * @throws SystemException if a system exception occurred
3840             */
3841            @Override
3842            public List<JournalArticle> findByStructureId(String[] structureIds,
3843                    int start, int end, OrderByComparator orderByComparator)
3844                    throws SystemException {
3845                    if ((structureIds != null) && (structureIds.length == 1)) {
3846                            return findByStructureId(structureIds[0], start, end,
3847                                    orderByComparator);
3848                    }
3849    
3850                    boolean pagination = true;
3851                    Object[] finderArgs = null;
3852    
3853                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3854                                    (orderByComparator == null)) {
3855                            pagination = false;
3856                            finderArgs = new Object[] { StringUtil.merge(structureIds) };
3857                    }
3858                    else {
3859                            finderArgs = new Object[] {
3860                                            StringUtil.merge(structureIds),
3861                                            
3862                                            start, end, orderByComparator
3863                                    };
3864                    }
3865    
3866                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3867                                    finderArgs, this);
3868    
3869                    if ((list != null) && !list.isEmpty()) {
3870                            for (JournalArticle journalArticle : list) {
3871                                    if (!ArrayUtil.contains(structureIds,
3872                                                            journalArticle.getStructureId())) {
3873                                            list = null;
3874    
3875                                            break;
3876                                    }
3877                            }
3878                    }
3879    
3880                    if (list == null) {
3881                            StringBundler query = new StringBundler();
3882    
3883                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3884    
3885                            boolean conjunctionable = false;
3886    
3887                            if ((structureIds == null) || (structureIds.length > 0)) {
3888                                    if (conjunctionable) {
3889                                            query.append(WHERE_AND);
3890                                    }
3891    
3892                                    query.append(StringPool.OPEN_PARENTHESIS);
3893    
3894                                    for (int i = 0; i < structureIds.length; i++) {
3895                                            String structureId = structureIds[i];
3896    
3897                                            if (structureId == null) {
3898                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
3899                                            }
3900                                            else if (structureId.equals(StringPool.BLANK)) {
3901                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
3902                                            }
3903                                            else {
3904                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
3905                                            }
3906    
3907                                            if ((i + 1) < structureIds.length) {
3908                                                    query.append(WHERE_OR);
3909                                            }
3910                                    }
3911    
3912                                    query.append(StringPool.CLOSE_PARENTHESIS);
3913    
3914                                    conjunctionable = true;
3915                            }
3916    
3917                            if (orderByComparator != null) {
3918                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3919                                            orderByComparator);
3920                            }
3921                            else
3922                             if (pagination) {
3923                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3924                            }
3925    
3926                            String sql = query.toString();
3927    
3928                            Session session = null;
3929    
3930                            try {
3931                                    session = openSession();
3932    
3933                                    Query q = session.createQuery(sql);
3934    
3935                                    QueryPos qPos = QueryPos.getInstance(q);
3936    
3937                                    if (structureIds != null) {
3938                                            qPos.add(structureIds);
3939                                    }
3940    
3941                                    if (!pagination) {
3942                                            list = (List<JournalArticle>)QueryUtil.list(q,
3943                                                            getDialect(), start, end, false);
3944    
3945                                            Collections.sort(list);
3946    
3947                                            list = new UnmodifiableList<JournalArticle>(list);
3948                                    }
3949                                    else {
3950                                            list = (List<JournalArticle>)QueryUtil.list(q,
3951                                                            getDialect(), start, end);
3952                                    }
3953    
3954                                    cacheResult(list);
3955    
3956                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3957                                            finderArgs, list);
3958                            }
3959                            catch (Exception e) {
3960                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3961                                            finderArgs);
3962    
3963                                    throw processException(e);
3964                            }
3965                            finally {
3966                                    closeSession(session);
3967                            }
3968                    }
3969    
3970                    return list;
3971            }
3972    
3973            /**
3974             * Removes all the journal articles where structureId = &#63; from the database.
3975             *
3976             * @param structureId the structure ID
3977             * @throws SystemException if a system exception occurred
3978             */
3979            @Override
3980            public void removeByStructureId(String structureId)
3981                    throws SystemException {
3982                    for (JournalArticle journalArticle : findByStructureId(structureId,
3983                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3984                            remove(journalArticle);
3985                    }
3986            }
3987    
3988            /**
3989             * Returns the number of journal articles where structureId = &#63;.
3990             *
3991             * @param structureId the structure ID
3992             * @return the number of matching journal articles
3993             * @throws SystemException if a system exception occurred
3994             */
3995            @Override
3996            public int countByStructureId(String structureId) throws SystemException {
3997                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
3998    
3999                    Object[] finderArgs = new Object[] { structureId };
4000    
4001                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4002                                    this);
4003    
4004                    if (count == null) {
4005                            StringBundler query = new StringBundler(2);
4006    
4007                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4008    
4009                            boolean bindStructureId = false;
4010    
4011                            if (structureId == null) {
4012                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4013                            }
4014                            else if (structureId.equals(StringPool.BLANK)) {
4015                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4016                            }
4017                            else {
4018                                    bindStructureId = true;
4019    
4020                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4021                            }
4022    
4023                            String sql = query.toString();
4024    
4025                            Session session = null;
4026    
4027                            try {
4028                                    session = openSession();
4029    
4030                                    Query q = session.createQuery(sql);
4031    
4032                                    QueryPos qPos = QueryPos.getInstance(q);
4033    
4034                                    if (bindStructureId) {
4035                                            qPos.add(structureId);
4036                                    }
4037    
4038                                    count = (Long)q.uniqueResult();
4039    
4040                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4041                            }
4042                            catch (Exception e) {
4043                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4044    
4045                                    throw processException(e);
4046                            }
4047                            finally {
4048                                    closeSession(session);
4049                            }
4050                    }
4051    
4052                    return count.intValue();
4053            }
4054    
4055            /**
4056             * Returns the number of journal articles where structureId = any &#63;.
4057             *
4058             * @param structureIds the structure IDs
4059             * @return the number of matching journal articles
4060             * @throws SystemException if a system exception occurred
4061             */
4062            @Override
4063            public int countByStructureId(String[] structureIds)
4064                    throws SystemException {
4065                    Object[] finderArgs = new Object[] { StringUtil.merge(structureIds) };
4066    
4067                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4068                                    finderArgs, this);
4069    
4070                    if (count == null) {
4071                            StringBundler query = new StringBundler();
4072    
4073                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4074    
4075                            boolean conjunctionable = false;
4076    
4077                            if ((structureIds == null) || (structureIds.length > 0)) {
4078                                    if (conjunctionable) {
4079                                            query.append(WHERE_AND);
4080                                    }
4081    
4082                                    query.append(StringPool.OPEN_PARENTHESIS);
4083    
4084                                    for (int i = 0; i < structureIds.length; i++) {
4085                                            String structureId = structureIds[i];
4086    
4087                                            if (structureId == null) {
4088                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
4089                                            }
4090                                            else if (structureId.equals(StringPool.BLANK)) {
4091                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
4092                                            }
4093                                            else {
4094                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
4095                                            }
4096    
4097                                            if ((i + 1) < structureIds.length) {
4098                                                    query.append(WHERE_OR);
4099                                            }
4100                                    }
4101    
4102                                    query.append(StringPool.CLOSE_PARENTHESIS);
4103    
4104                                    conjunctionable = true;
4105                            }
4106    
4107                            String sql = query.toString();
4108    
4109                            Session session = null;
4110    
4111                            try {
4112                                    session = openSession();
4113    
4114                                    Query q = session.createQuery(sql);
4115    
4116                                    QueryPos qPos = QueryPos.getInstance(q);
4117    
4118                                    if (structureIds != null) {
4119                                            qPos.add(structureIds);
4120                                    }
4121    
4122                                    count = (Long)q.uniqueResult();
4123    
4124                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4125                                            finderArgs, count);
4126                            }
4127                            catch (Exception e) {
4128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4129                                            finderArgs);
4130    
4131                                    throw processException(e);
4132                            }
4133                            finally {
4134                                    closeSession(session);
4135                            }
4136                    }
4137    
4138                    return count.intValue();
4139            }
4140    
4141            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
4142            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
4143            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
4144            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4 = "(" +
4145                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1) + ")";
4146            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5 = "(" +
4147                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2) + ")";
4148            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6 = "(" +
4149                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3) + ")";
4150            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
4151                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4152                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4153                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4154                            "findByTemplateId",
4155                            new String[] {
4156                                    String.class.getName(),
4157                                    
4158                            Integer.class.getName(), Integer.class.getName(),
4159                                    OrderByComparator.class.getName()
4160                            });
4161            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
4162                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4163                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4164                            JournalArticleImpl.class,
4165                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
4166                            new String[] { String.class.getName() },
4167                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
4168                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4169                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4170            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4171                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4172                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
4173                            new String[] { String.class.getName() });
4174    
4175            /**
4176             * Returns all the journal articles where templateId = &#63;.
4177             *
4178             * @param templateId the template ID
4179             * @return the matching journal articles
4180             * @throws SystemException if a system exception occurred
4181             */
4182            @Override
4183            public List<JournalArticle> findByTemplateId(String templateId)
4184                    throws SystemException {
4185                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4186                            QueryUtil.ALL_POS, null);
4187            }
4188    
4189            /**
4190             * Returns a range of all the journal articles where templateId = &#63;.
4191             *
4192             * <p>
4193             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4194             * </p>
4195             *
4196             * @param templateId the template ID
4197             * @param start the lower bound of the range of journal articles
4198             * @param end the upper bound of the range of journal articles (not inclusive)
4199             * @return the range of matching journal articles
4200             * @throws SystemException if a system exception occurred
4201             */
4202            @Override
4203            public List<JournalArticle> findByTemplateId(String templateId, int start,
4204                    int end) throws SystemException {
4205                    return findByTemplateId(templateId, start, end, null);
4206            }
4207    
4208            /**
4209             * Returns an ordered range of all the journal articles where templateId = &#63;.
4210             *
4211             * <p>
4212             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4213             * </p>
4214             *
4215             * @param templateId the template ID
4216             * @param start the lower bound of the range of journal articles
4217             * @param end the upper bound of the range of journal articles (not inclusive)
4218             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4219             * @return the ordered range of matching journal articles
4220             * @throws SystemException if a system exception occurred
4221             */
4222            @Override
4223            public List<JournalArticle> findByTemplateId(String templateId, int start,
4224                    int end, OrderByComparator orderByComparator) throws SystemException {
4225                    boolean pagination = true;
4226                    FinderPath finderPath = null;
4227                    Object[] finderArgs = null;
4228    
4229                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4230                                    (orderByComparator == null)) {
4231                            pagination = false;
4232                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4233                            finderArgs = new Object[] { templateId };
4234                    }
4235                    else {
4236                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4237                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4238                    }
4239    
4240                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4241                                    finderArgs, this);
4242    
4243                    if ((list != null) && !list.isEmpty()) {
4244                            for (JournalArticle journalArticle : list) {
4245                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4246                                            list = null;
4247    
4248                                            break;
4249                                    }
4250                            }
4251                    }
4252    
4253                    if (list == null) {
4254                            StringBundler query = null;
4255    
4256                            if (orderByComparator != null) {
4257                                    query = new StringBundler(3 +
4258                                                    (orderByComparator.getOrderByFields().length * 3));
4259                            }
4260                            else {
4261                                    query = new StringBundler(3);
4262                            }
4263    
4264                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4265    
4266                            boolean bindTemplateId = false;
4267    
4268                            if (templateId == null) {
4269                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4270                            }
4271                            else if (templateId.equals(StringPool.BLANK)) {
4272                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4273                            }
4274                            else {
4275                                    bindTemplateId = true;
4276    
4277                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4278                            }
4279    
4280                            if (orderByComparator != null) {
4281                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4282                                            orderByComparator);
4283                            }
4284                            else
4285                             if (pagination) {
4286                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4287                            }
4288    
4289                            String sql = query.toString();
4290    
4291                            Session session = null;
4292    
4293                            try {
4294                                    session = openSession();
4295    
4296                                    Query q = session.createQuery(sql);
4297    
4298                                    QueryPos qPos = QueryPos.getInstance(q);
4299    
4300                                    if (bindTemplateId) {
4301                                            qPos.add(templateId);
4302                                    }
4303    
4304                                    if (!pagination) {
4305                                            list = (List<JournalArticle>)QueryUtil.list(q,
4306                                                            getDialect(), start, end, false);
4307    
4308                                            Collections.sort(list);
4309    
4310                                            list = new UnmodifiableList<JournalArticle>(list);
4311                                    }
4312                                    else {
4313                                            list = (List<JournalArticle>)QueryUtil.list(q,
4314                                                            getDialect(), start, end);
4315                                    }
4316    
4317                                    cacheResult(list);
4318    
4319                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4320                            }
4321                            catch (Exception e) {
4322                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4323    
4324                                    throw processException(e);
4325                            }
4326                            finally {
4327                                    closeSession(session);
4328                            }
4329                    }
4330    
4331                    return list;
4332            }
4333    
4334            /**
4335             * Returns the first journal article in the ordered set where templateId = &#63;.
4336             *
4337             * @param templateId the template ID
4338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4339             * @return the first matching journal article
4340             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4341             * @throws SystemException if a system exception occurred
4342             */
4343            @Override
4344            public JournalArticle findByTemplateId_First(String templateId,
4345                    OrderByComparator orderByComparator)
4346                    throws NoSuchArticleException, SystemException {
4347                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4348                                    orderByComparator);
4349    
4350                    if (journalArticle != null) {
4351                            return journalArticle;
4352                    }
4353    
4354                    StringBundler msg = new StringBundler(4);
4355    
4356                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4357    
4358                    msg.append("templateId=");
4359                    msg.append(templateId);
4360    
4361                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4362    
4363                    throw new NoSuchArticleException(msg.toString());
4364            }
4365    
4366            /**
4367             * Returns the first journal article in the ordered set where templateId = &#63;.
4368             *
4369             * @param templateId the template ID
4370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4371             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4372             * @throws SystemException if a system exception occurred
4373             */
4374            @Override
4375            public JournalArticle fetchByTemplateId_First(String templateId,
4376                    OrderByComparator orderByComparator) throws SystemException {
4377                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4378                                    orderByComparator);
4379    
4380                    if (!list.isEmpty()) {
4381                            return list.get(0);
4382                    }
4383    
4384                    return null;
4385            }
4386    
4387            /**
4388             * Returns the last journal article in the ordered set where templateId = &#63;.
4389             *
4390             * @param templateId the template ID
4391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4392             * @return the last matching journal article
4393             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4394             * @throws SystemException if a system exception occurred
4395             */
4396            @Override
4397            public JournalArticle findByTemplateId_Last(String templateId,
4398                    OrderByComparator orderByComparator)
4399                    throws NoSuchArticleException, SystemException {
4400                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4401                                    orderByComparator);
4402    
4403                    if (journalArticle != null) {
4404                            return journalArticle;
4405                    }
4406    
4407                    StringBundler msg = new StringBundler(4);
4408    
4409                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4410    
4411                    msg.append("templateId=");
4412                    msg.append(templateId);
4413    
4414                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4415    
4416                    throw new NoSuchArticleException(msg.toString());
4417            }
4418    
4419            /**
4420             * Returns the last journal article in the ordered set where templateId = &#63;.
4421             *
4422             * @param templateId the template ID
4423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4424             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4425             * @throws SystemException if a system exception occurred
4426             */
4427            @Override
4428            public JournalArticle fetchByTemplateId_Last(String templateId,
4429                    OrderByComparator orderByComparator) throws SystemException {
4430                    int count = countByTemplateId(templateId);
4431    
4432                    if (count == 0) {
4433                            return null;
4434                    }
4435    
4436                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4437                                    count, orderByComparator);
4438    
4439                    if (!list.isEmpty()) {
4440                            return list.get(0);
4441                    }
4442    
4443                    return null;
4444            }
4445    
4446            /**
4447             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4448             *
4449             * @param id the primary key of the current journal article
4450             * @param templateId the template ID
4451             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4452             * @return the previous, current, and next journal article
4453             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4454             * @throws SystemException if a system exception occurred
4455             */
4456            @Override
4457            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4458                    String templateId, OrderByComparator orderByComparator)
4459                    throws NoSuchArticleException, SystemException {
4460                    JournalArticle journalArticle = findByPrimaryKey(id);
4461    
4462                    Session session = null;
4463    
4464                    try {
4465                            session = openSession();
4466    
4467                            JournalArticle[] array = new JournalArticleImpl[3];
4468    
4469                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4470                                            templateId, orderByComparator, true);
4471    
4472                            array[1] = journalArticle;
4473    
4474                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4475                                            templateId, orderByComparator, false);
4476    
4477                            return array;
4478                    }
4479                    catch (Exception e) {
4480                            throw processException(e);
4481                    }
4482                    finally {
4483                            closeSession(session);
4484                    }
4485            }
4486    
4487            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4488                    JournalArticle journalArticle, String templateId,
4489                    OrderByComparator orderByComparator, boolean previous) {
4490                    StringBundler query = null;
4491    
4492                    if (orderByComparator != null) {
4493                            query = new StringBundler(6 +
4494                                            (orderByComparator.getOrderByFields().length * 6));
4495                    }
4496                    else {
4497                            query = new StringBundler(3);
4498                    }
4499    
4500                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4501    
4502                    boolean bindTemplateId = false;
4503    
4504                    if (templateId == null) {
4505                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4506                    }
4507                    else if (templateId.equals(StringPool.BLANK)) {
4508                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4509                    }
4510                    else {
4511                            bindTemplateId = true;
4512    
4513                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4514                    }
4515    
4516                    if (orderByComparator != null) {
4517                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4518    
4519                            if (orderByConditionFields.length > 0) {
4520                                    query.append(WHERE_AND);
4521                            }
4522    
4523                            for (int i = 0; i < orderByConditionFields.length; i++) {
4524                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4525                                    query.append(orderByConditionFields[i]);
4526    
4527                                    if ((i + 1) < orderByConditionFields.length) {
4528                                            if (orderByComparator.isAscending() ^ previous) {
4529                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4530                                            }
4531                                            else {
4532                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4533                                            }
4534                                    }
4535                                    else {
4536                                            if (orderByComparator.isAscending() ^ previous) {
4537                                                    query.append(WHERE_GREATER_THAN);
4538                                            }
4539                                            else {
4540                                                    query.append(WHERE_LESSER_THAN);
4541                                            }
4542                                    }
4543                            }
4544    
4545                            query.append(ORDER_BY_CLAUSE);
4546    
4547                            String[] orderByFields = orderByComparator.getOrderByFields();
4548    
4549                            for (int i = 0; i < orderByFields.length; i++) {
4550                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4551                                    query.append(orderByFields[i]);
4552    
4553                                    if ((i + 1) < orderByFields.length) {
4554                                            if (orderByComparator.isAscending() ^ previous) {
4555                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4556                                            }
4557                                            else {
4558                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4559                                            }
4560                                    }
4561                                    else {
4562                                            if (orderByComparator.isAscending() ^ previous) {
4563                                                    query.append(ORDER_BY_ASC);
4564                                            }
4565                                            else {
4566                                                    query.append(ORDER_BY_DESC);
4567                                            }
4568                                    }
4569                            }
4570                    }
4571                    else {
4572                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4573                    }
4574    
4575                    String sql = query.toString();
4576    
4577                    Query q = session.createQuery(sql);
4578    
4579                    q.setFirstResult(0);
4580                    q.setMaxResults(2);
4581    
4582                    QueryPos qPos = QueryPos.getInstance(q);
4583    
4584                    if (bindTemplateId) {
4585                            qPos.add(templateId);
4586                    }
4587    
4588                    if (orderByComparator != null) {
4589                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4590    
4591                            for (Object value : values) {
4592                                    qPos.add(value);
4593                            }
4594                    }
4595    
4596                    List<JournalArticle> list = q.list();
4597    
4598                    if (list.size() == 2) {
4599                            return list.get(1);
4600                    }
4601                    else {
4602                            return null;
4603                    }
4604            }
4605    
4606            /**
4607             * Removes all the journal articles where templateId = &#63; from the database.
4608             *
4609             * @param templateId the template ID
4610             * @throws SystemException if a system exception occurred
4611             */
4612            @Override
4613            public void removeByTemplateId(String templateId) throws SystemException {
4614                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4615                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4616                            remove(journalArticle);
4617                    }
4618            }
4619    
4620            /**
4621             * Returns the number of journal articles where templateId = &#63;.
4622             *
4623             * @param templateId the template ID
4624             * @return the number of matching journal articles
4625             * @throws SystemException if a system exception occurred
4626             */
4627            @Override
4628            public int countByTemplateId(String templateId) throws SystemException {
4629                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4630    
4631                    Object[] finderArgs = new Object[] { templateId };
4632    
4633                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4634                                    this);
4635    
4636                    if (count == null) {
4637                            StringBundler query = new StringBundler(2);
4638    
4639                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4640    
4641                            boolean bindTemplateId = false;
4642    
4643                            if (templateId == null) {
4644                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4645                            }
4646                            else if (templateId.equals(StringPool.BLANK)) {
4647                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4648                            }
4649                            else {
4650                                    bindTemplateId = true;
4651    
4652                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4653                            }
4654    
4655                            String sql = query.toString();
4656    
4657                            Session session = null;
4658    
4659                            try {
4660                                    session = openSession();
4661    
4662                                    Query q = session.createQuery(sql);
4663    
4664                                    QueryPos qPos = QueryPos.getInstance(q);
4665    
4666                                    if (bindTemplateId) {
4667                                            qPos.add(templateId);
4668                                    }
4669    
4670                                    count = (Long)q.uniqueResult();
4671    
4672                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4673                            }
4674                            catch (Exception e) {
4675                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4676    
4677                                    throw processException(e);
4678                            }
4679                            finally {
4680                                    closeSession(session);
4681                            }
4682                    }
4683    
4684                    return count.intValue();
4685            }
4686    
4687            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4688            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4689            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
4690            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4691                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4692                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4693                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4694                            "findByLayoutUuid",
4695                            new String[] {
4696                                    String.class.getName(),
4697                                    
4698                            Integer.class.getName(), Integer.class.getName(),
4699                                    OrderByComparator.class.getName()
4700                            });
4701            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4702                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4703                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4704                            JournalArticleImpl.class,
4705                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4706                            new String[] { String.class.getName() },
4707                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4708                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4709                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4710            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4711                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4712                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4713                            new String[] { String.class.getName() });
4714    
4715            /**
4716             * Returns all the journal articles where layoutUuid = &#63;.
4717             *
4718             * @param layoutUuid the layout uuid
4719             * @return the matching journal articles
4720             * @throws SystemException if a system exception occurred
4721             */
4722            @Override
4723            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
4724                    throws SystemException {
4725                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4726                            QueryUtil.ALL_POS, null);
4727            }
4728    
4729            /**
4730             * Returns a range of all the journal articles where layoutUuid = &#63;.
4731             *
4732             * <p>
4733             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4734             * </p>
4735             *
4736             * @param layoutUuid the layout uuid
4737             * @param start the lower bound of the range of journal articles
4738             * @param end the upper bound of the range of journal articles (not inclusive)
4739             * @return the range of matching journal articles
4740             * @throws SystemException if a system exception occurred
4741             */
4742            @Override
4743            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4744                    int end) throws SystemException {
4745                    return findByLayoutUuid(layoutUuid, start, end, null);
4746            }
4747    
4748            /**
4749             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4750             *
4751             * <p>
4752             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4753             * </p>
4754             *
4755             * @param layoutUuid the layout uuid
4756             * @param start the lower bound of the range of journal articles
4757             * @param end the upper bound of the range of journal articles (not inclusive)
4758             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4759             * @return the ordered range of matching journal articles
4760             * @throws SystemException if a system exception occurred
4761             */
4762            @Override
4763            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4764                    int end, OrderByComparator orderByComparator) throws SystemException {
4765                    boolean pagination = true;
4766                    FinderPath finderPath = null;
4767                    Object[] finderArgs = null;
4768    
4769                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4770                                    (orderByComparator == null)) {
4771                            pagination = false;
4772                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4773                            finderArgs = new Object[] { layoutUuid };
4774                    }
4775                    else {
4776                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4777                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4778                    }
4779    
4780                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4781                                    finderArgs, this);
4782    
4783                    if ((list != null) && !list.isEmpty()) {
4784                            for (JournalArticle journalArticle : list) {
4785                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4786                                            list = null;
4787    
4788                                            break;
4789                                    }
4790                            }
4791                    }
4792    
4793                    if (list == null) {
4794                            StringBundler query = null;
4795    
4796                            if (orderByComparator != null) {
4797                                    query = new StringBundler(3 +
4798                                                    (orderByComparator.getOrderByFields().length * 3));
4799                            }
4800                            else {
4801                                    query = new StringBundler(3);
4802                            }
4803    
4804                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4805    
4806                            boolean bindLayoutUuid = false;
4807    
4808                            if (layoutUuid == null) {
4809                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4810                            }
4811                            else if (layoutUuid.equals(StringPool.BLANK)) {
4812                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4813                            }
4814                            else {
4815                                    bindLayoutUuid = true;
4816    
4817                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4818                            }
4819    
4820                            if (orderByComparator != null) {
4821                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4822                                            orderByComparator);
4823                            }
4824                            else
4825                             if (pagination) {
4826                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4827                            }
4828    
4829                            String sql = query.toString();
4830    
4831                            Session session = null;
4832    
4833                            try {
4834                                    session = openSession();
4835    
4836                                    Query q = session.createQuery(sql);
4837    
4838                                    QueryPos qPos = QueryPos.getInstance(q);
4839    
4840                                    if (bindLayoutUuid) {
4841                                            qPos.add(layoutUuid);
4842                                    }
4843    
4844                                    if (!pagination) {
4845                                            list = (List<JournalArticle>)QueryUtil.list(q,
4846                                                            getDialect(), start, end, false);
4847    
4848                                            Collections.sort(list);
4849    
4850                                            list = new UnmodifiableList<JournalArticle>(list);
4851                                    }
4852                                    else {
4853                                            list = (List<JournalArticle>)QueryUtil.list(q,
4854                                                            getDialect(), start, end);
4855                                    }
4856    
4857                                    cacheResult(list);
4858    
4859                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4860                            }
4861                            catch (Exception e) {
4862                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4863    
4864                                    throw processException(e);
4865                            }
4866                            finally {
4867                                    closeSession(session);
4868                            }
4869                    }
4870    
4871                    return list;
4872            }
4873    
4874            /**
4875             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4876             *
4877             * @param layoutUuid the layout uuid
4878             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4879             * @return the first matching journal article
4880             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4881             * @throws SystemException if a system exception occurred
4882             */
4883            @Override
4884            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4885                    OrderByComparator orderByComparator)
4886                    throws NoSuchArticleException, SystemException {
4887                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4888                                    orderByComparator);
4889    
4890                    if (journalArticle != null) {
4891                            return journalArticle;
4892                    }
4893    
4894                    StringBundler msg = new StringBundler(4);
4895    
4896                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4897    
4898                    msg.append("layoutUuid=");
4899                    msg.append(layoutUuid);
4900    
4901                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4902    
4903                    throw new NoSuchArticleException(msg.toString());
4904            }
4905    
4906            /**
4907             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4908             *
4909             * @param layoutUuid the layout uuid
4910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4911             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4912             * @throws SystemException if a system exception occurred
4913             */
4914            @Override
4915            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4916                    OrderByComparator orderByComparator) throws SystemException {
4917                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4918                                    orderByComparator);
4919    
4920                    if (!list.isEmpty()) {
4921                            return list.get(0);
4922                    }
4923    
4924                    return null;
4925            }
4926    
4927            /**
4928             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4929             *
4930             * @param layoutUuid the layout uuid
4931             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4932             * @return the last matching journal article
4933             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4934             * @throws SystemException if a system exception occurred
4935             */
4936            @Override
4937            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4938                    OrderByComparator orderByComparator)
4939                    throws NoSuchArticleException, SystemException {
4940                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4941                                    orderByComparator);
4942    
4943                    if (journalArticle != null) {
4944                            return journalArticle;
4945                    }
4946    
4947                    StringBundler msg = new StringBundler(4);
4948    
4949                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4950    
4951                    msg.append("layoutUuid=");
4952                    msg.append(layoutUuid);
4953    
4954                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4955    
4956                    throw new NoSuchArticleException(msg.toString());
4957            }
4958    
4959            /**
4960             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4961             *
4962             * @param layoutUuid the layout uuid
4963             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4964             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4965             * @throws SystemException if a system exception occurred
4966             */
4967            @Override
4968            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4969                    OrderByComparator orderByComparator) throws SystemException {
4970                    int count = countByLayoutUuid(layoutUuid);
4971    
4972                    if (count == 0) {
4973                            return null;
4974                    }
4975    
4976                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4977                                    count, orderByComparator);
4978    
4979                    if (!list.isEmpty()) {
4980                            return list.get(0);
4981                    }
4982    
4983                    return null;
4984            }
4985    
4986            /**
4987             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4988             *
4989             * @param id the primary key of the current journal article
4990             * @param layoutUuid the layout uuid
4991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4992             * @return the previous, current, and next journal article
4993             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4994             * @throws SystemException if a system exception occurred
4995             */
4996            @Override
4997            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4998                    String layoutUuid, OrderByComparator orderByComparator)
4999                    throws NoSuchArticleException, SystemException {
5000                    JournalArticle journalArticle = findByPrimaryKey(id);
5001    
5002                    Session session = null;
5003    
5004                    try {
5005                            session = openSession();
5006    
5007                            JournalArticle[] array = new JournalArticleImpl[3];
5008    
5009                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5010                                            layoutUuid, orderByComparator, true);
5011    
5012                            array[1] = journalArticle;
5013    
5014                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5015                                            layoutUuid, orderByComparator, false);
5016    
5017                            return array;
5018                    }
5019                    catch (Exception e) {
5020                            throw processException(e);
5021                    }
5022                    finally {
5023                            closeSession(session);
5024                    }
5025            }
5026    
5027            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
5028                    JournalArticle journalArticle, String layoutUuid,
5029                    OrderByComparator orderByComparator, boolean previous) {
5030                    StringBundler query = null;
5031    
5032                    if (orderByComparator != null) {
5033                            query = new StringBundler(6 +
5034                                            (orderByComparator.getOrderByFields().length * 6));
5035                    }
5036                    else {
5037                            query = new StringBundler(3);
5038                    }
5039    
5040                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5041    
5042                    boolean bindLayoutUuid = false;
5043    
5044                    if (layoutUuid == null) {
5045                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5046                    }
5047                    else if (layoutUuid.equals(StringPool.BLANK)) {
5048                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5049                    }
5050                    else {
5051                            bindLayoutUuid = true;
5052    
5053                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5054                    }
5055    
5056                    if (orderByComparator != null) {
5057                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5058    
5059                            if (orderByConditionFields.length > 0) {
5060                                    query.append(WHERE_AND);
5061                            }
5062    
5063                            for (int i = 0; i < orderByConditionFields.length; i++) {
5064                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5065                                    query.append(orderByConditionFields[i]);
5066    
5067                                    if ((i + 1) < orderByConditionFields.length) {
5068                                            if (orderByComparator.isAscending() ^ previous) {
5069                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5070                                            }
5071                                            else {
5072                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5073                                            }
5074                                    }
5075                                    else {
5076                                            if (orderByComparator.isAscending() ^ previous) {
5077                                                    query.append(WHERE_GREATER_THAN);
5078                                            }
5079                                            else {
5080                                                    query.append(WHERE_LESSER_THAN);
5081                                            }
5082                                    }
5083                            }
5084    
5085                            query.append(ORDER_BY_CLAUSE);
5086    
5087                            String[] orderByFields = orderByComparator.getOrderByFields();
5088    
5089                            for (int i = 0; i < orderByFields.length; i++) {
5090                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5091                                    query.append(orderByFields[i]);
5092    
5093                                    if ((i + 1) < orderByFields.length) {
5094                                            if (orderByComparator.isAscending() ^ previous) {
5095                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5096                                            }
5097                                            else {
5098                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5099                                            }
5100                                    }
5101                                    else {
5102                                            if (orderByComparator.isAscending() ^ previous) {
5103                                                    query.append(ORDER_BY_ASC);
5104                                            }
5105                                            else {
5106                                                    query.append(ORDER_BY_DESC);
5107                                            }
5108                                    }
5109                            }
5110                    }
5111                    else {
5112                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5113                    }
5114    
5115                    String sql = query.toString();
5116    
5117                    Query q = session.createQuery(sql);
5118    
5119                    q.setFirstResult(0);
5120                    q.setMaxResults(2);
5121    
5122                    QueryPos qPos = QueryPos.getInstance(q);
5123    
5124                    if (bindLayoutUuid) {
5125                            qPos.add(layoutUuid);
5126                    }
5127    
5128                    if (orderByComparator != null) {
5129                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5130    
5131                            for (Object value : values) {
5132                                    qPos.add(value);
5133                            }
5134                    }
5135    
5136                    List<JournalArticle> list = q.list();
5137    
5138                    if (list.size() == 2) {
5139                            return list.get(1);
5140                    }
5141                    else {
5142                            return null;
5143                    }
5144            }
5145    
5146            /**
5147             * Removes all the journal articles where layoutUuid = &#63; from the database.
5148             *
5149             * @param layoutUuid the layout uuid
5150             * @throws SystemException if a system exception occurred
5151             */
5152            @Override
5153            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
5154                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
5155                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5156                            remove(journalArticle);
5157                    }
5158            }
5159    
5160            /**
5161             * Returns the number of journal articles where layoutUuid = &#63;.
5162             *
5163             * @param layoutUuid the layout uuid
5164             * @return the number of matching journal articles
5165             * @throws SystemException if a system exception occurred
5166             */
5167            @Override
5168            public int countByLayoutUuid(String layoutUuid) throws SystemException {
5169                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
5170    
5171                    Object[] finderArgs = new Object[] { layoutUuid };
5172    
5173                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5174                                    this);
5175    
5176                    if (count == null) {
5177                            StringBundler query = new StringBundler(2);
5178    
5179                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5180    
5181                            boolean bindLayoutUuid = false;
5182    
5183                            if (layoutUuid == null) {
5184                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5185                            }
5186                            else if (layoutUuid.equals(StringPool.BLANK)) {
5187                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5188                            }
5189                            else {
5190                                    bindLayoutUuid = true;
5191    
5192                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5193                            }
5194    
5195                            String sql = query.toString();
5196    
5197                            Session session = null;
5198    
5199                            try {
5200                                    session = openSession();
5201    
5202                                    Query q = session.createQuery(sql);
5203    
5204                                    QueryPos qPos = QueryPos.getInstance(q);
5205    
5206                                    if (bindLayoutUuid) {
5207                                            qPos.add(layoutUuid);
5208                                    }
5209    
5210                                    count = (Long)q.uniqueResult();
5211    
5212                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5213                            }
5214                            catch (Exception e) {
5215                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5216    
5217                                    throw processException(e);
5218                            }
5219                            finally {
5220                                    closeSession(session);
5221                            }
5222                    }
5223    
5224                    return count.intValue();
5225            }
5226    
5227            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
5228            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
5229            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
5230            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
5231                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5232                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5233                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5234                            "findBySmallImageId",
5235                            new String[] {
5236                                    Long.class.getName(),
5237                                    
5238                            Integer.class.getName(), Integer.class.getName(),
5239                                    OrderByComparator.class.getName()
5240                            });
5241            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
5242                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5243                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5244                            JournalArticleImpl.class,
5245                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
5246                            new String[] { Long.class.getName() },
5247                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
5248                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5249                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5250            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5251                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5252                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
5253                            new String[] { Long.class.getName() });
5254    
5255            /**
5256             * Returns all the journal articles where smallImageId = &#63;.
5257             *
5258             * @param smallImageId the small image ID
5259             * @return the matching journal articles
5260             * @throws SystemException if a system exception occurred
5261             */
5262            @Override
5263            public List<JournalArticle> findBySmallImageId(long smallImageId)
5264                    throws SystemException {
5265                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5266                            QueryUtil.ALL_POS, null);
5267            }
5268    
5269            /**
5270             * Returns a range of all the journal articles where smallImageId = &#63;.
5271             *
5272             * <p>
5273             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5274             * </p>
5275             *
5276             * @param smallImageId the small image ID
5277             * @param start the lower bound of the range of journal articles
5278             * @param end the upper bound of the range of journal articles (not inclusive)
5279             * @return the range of matching journal articles
5280             * @throws SystemException if a system exception occurred
5281             */
5282            @Override
5283            public List<JournalArticle> findBySmallImageId(long smallImageId,
5284                    int start, int end) throws SystemException {
5285                    return findBySmallImageId(smallImageId, start, end, null);
5286            }
5287    
5288            /**
5289             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5290             *
5291             * <p>
5292             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5293             * </p>
5294             *
5295             * @param smallImageId the small image ID
5296             * @param start the lower bound of the range of journal articles
5297             * @param end the upper bound of the range of journal articles (not inclusive)
5298             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5299             * @return the ordered range of matching journal articles
5300             * @throws SystemException if a system exception occurred
5301             */
5302            @Override
5303            public List<JournalArticle> findBySmallImageId(long smallImageId,
5304                    int start, int end, OrderByComparator orderByComparator)
5305                    throws SystemException {
5306                    boolean pagination = true;
5307                    FinderPath finderPath = null;
5308                    Object[] finderArgs = null;
5309    
5310                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5311                                    (orderByComparator == null)) {
5312                            pagination = false;
5313                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5314                            finderArgs = new Object[] { smallImageId };
5315                    }
5316                    else {
5317                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5318                            finderArgs = new Object[] {
5319                                            smallImageId,
5320                                            
5321                                            start, end, orderByComparator
5322                                    };
5323                    }
5324    
5325                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5326                                    finderArgs, this);
5327    
5328                    if ((list != null) && !list.isEmpty()) {
5329                            for (JournalArticle journalArticle : list) {
5330                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5331                                            list = null;
5332    
5333                                            break;
5334                                    }
5335                            }
5336                    }
5337    
5338                    if (list == null) {
5339                            StringBundler query = null;
5340    
5341                            if (orderByComparator != null) {
5342                                    query = new StringBundler(3 +
5343                                                    (orderByComparator.getOrderByFields().length * 3));
5344                            }
5345                            else {
5346                                    query = new StringBundler(3);
5347                            }
5348    
5349                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5350    
5351                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5352    
5353                            if (orderByComparator != null) {
5354                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5355                                            orderByComparator);
5356                            }
5357                            else
5358                             if (pagination) {
5359                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5360                            }
5361    
5362                            String sql = query.toString();
5363    
5364                            Session session = null;
5365    
5366                            try {
5367                                    session = openSession();
5368    
5369                                    Query q = session.createQuery(sql);
5370    
5371                                    QueryPos qPos = QueryPos.getInstance(q);
5372    
5373                                    qPos.add(smallImageId);
5374    
5375                                    if (!pagination) {
5376                                            list = (List<JournalArticle>)QueryUtil.list(q,
5377                                                            getDialect(), start, end, false);
5378    
5379                                            Collections.sort(list);
5380    
5381                                            list = new UnmodifiableList<JournalArticle>(list);
5382                                    }
5383                                    else {
5384                                            list = (List<JournalArticle>)QueryUtil.list(q,
5385                                                            getDialect(), start, end);
5386                                    }
5387    
5388                                    cacheResult(list);
5389    
5390                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5391                            }
5392                            catch (Exception e) {
5393                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5394    
5395                                    throw processException(e);
5396                            }
5397                            finally {
5398                                    closeSession(session);
5399                            }
5400                    }
5401    
5402                    return list;
5403            }
5404    
5405            /**
5406             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5407             *
5408             * @param smallImageId the small image ID
5409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5410             * @return the first matching journal article
5411             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5412             * @throws SystemException if a system exception occurred
5413             */
5414            @Override
5415            public JournalArticle findBySmallImageId_First(long smallImageId,
5416                    OrderByComparator orderByComparator)
5417                    throws NoSuchArticleException, SystemException {
5418                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5419                                    orderByComparator);
5420    
5421                    if (journalArticle != null) {
5422                            return journalArticle;
5423                    }
5424    
5425                    StringBundler msg = new StringBundler(4);
5426    
5427                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5428    
5429                    msg.append("smallImageId=");
5430                    msg.append(smallImageId);
5431    
5432                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5433    
5434                    throw new NoSuchArticleException(msg.toString());
5435            }
5436    
5437            /**
5438             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5439             *
5440             * @param smallImageId the small image ID
5441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5442             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5443             * @throws SystemException if a system exception occurred
5444             */
5445            @Override
5446            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5447                    OrderByComparator orderByComparator) throws SystemException {
5448                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5449                                    orderByComparator);
5450    
5451                    if (!list.isEmpty()) {
5452                            return list.get(0);
5453                    }
5454    
5455                    return null;
5456            }
5457    
5458            /**
5459             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5460             *
5461             * @param smallImageId the small image ID
5462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5463             * @return the last matching journal article
5464             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5465             * @throws SystemException if a system exception occurred
5466             */
5467            @Override
5468            public JournalArticle findBySmallImageId_Last(long smallImageId,
5469                    OrderByComparator orderByComparator)
5470                    throws NoSuchArticleException, SystemException {
5471                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5472                                    orderByComparator);
5473    
5474                    if (journalArticle != null) {
5475                            return journalArticle;
5476                    }
5477    
5478                    StringBundler msg = new StringBundler(4);
5479    
5480                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5481    
5482                    msg.append("smallImageId=");
5483                    msg.append(smallImageId);
5484    
5485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5486    
5487                    throw new NoSuchArticleException(msg.toString());
5488            }
5489    
5490            /**
5491             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5492             *
5493             * @param smallImageId the small image ID
5494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5495             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5496             * @throws SystemException if a system exception occurred
5497             */
5498            @Override
5499            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5500                    OrderByComparator orderByComparator) throws SystemException {
5501                    int count = countBySmallImageId(smallImageId);
5502    
5503                    if (count == 0) {
5504                            return null;
5505                    }
5506    
5507                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5508                                    count, orderByComparator);
5509    
5510                    if (!list.isEmpty()) {
5511                            return list.get(0);
5512                    }
5513    
5514                    return null;
5515            }
5516    
5517            /**
5518             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5519             *
5520             * @param id the primary key of the current journal article
5521             * @param smallImageId the small image ID
5522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5523             * @return the previous, current, and next journal article
5524             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5525             * @throws SystemException if a system exception occurred
5526             */
5527            @Override
5528            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5529                    long smallImageId, OrderByComparator orderByComparator)
5530                    throws NoSuchArticleException, SystemException {
5531                    JournalArticle journalArticle = findByPrimaryKey(id);
5532    
5533                    Session session = null;
5534    
5535                    try {
5536                            session = openSession();
5537    
5538                            JournalArticle[] array = new JournalArticleImpl[3];
5539    
5540                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5541                                            smallImageId, orderByComparator, true);
5542    
5543                            array[1] = journalArticle;
5544    
5545                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5546                                            smallImageId, orderByComparator, false);
5547    
5548                            return array;
5549                    }
5550                    catch (Exception e) {
5551                            throw processException(e);
5552                    }
5553                    finally {
5554                            closeSession(session);
5555                    }
5556            }
5557    
5558            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5559                    JournalArticle journalArticle, long smallImageId,
5560                    OrderByComparator orderByComparator, boolean previous) {
5561                    StringBundler query = null;
5562    
5563                    if (orderByComparator != null) {
5564                            query = new StringBundler(6 +
5565                                            (orderByComparator.getOrderByFields().length * 6));
5566                    }
5567                    else {
5568                            query = new StringBundler(3);
5569                    }
5570    
5571                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5572    
5573                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5574    
5575                    if (orderByComparator != null) {
5576                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5577    
5578                            if (orderByConditionFields.length > 0) {
5579                                    query.append(WHERE_AND);
5580                            }
5581    
5582                            for (int i = 0; i < orderByConditionFields.length; i++) {
5583                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5584                                    query.append(orderByConditionFields[i]);
5585    
5586                                    if ((i + 1) < orderByConditionFields.length) {
5587                                            if (orderByComparator.isAscending() ^ previous) {
5588                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5589                                            }
5590                                            else {
5591                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5592                                            }
5593                                    }
5594                                    else {
5595                                            if (orderByComparator.isAscending() ^ previous) {
5596                                                    query.append(WHERE_GREATER_THAN);
5597                                            }
5598                                            else {
5599                                                    query.append(WHERE_LESSER_THAN);
5600                                            }
5601                                    }
5602                            }
5603    
5604                            query.append(ORDER_BY_CLAUSE);
5605    
5606                            String[] orderByFields = orderByComparator.getOrderByFields();
5607    
5608                            for (int i = 0; i < orderByFields.length; i++) {
5609                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5610                                    query.append(orderByFields[i]);
5611    
5612                                    if ((i + 1) < orderByFields.length) {
5613                                            if (orderByComparator.isAscending() ^ previous) {
5614                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5615                                            }
5616                                            else {
5617                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5618                                            }
5619                                    }
5620                                    else {
5621                                            if (orderByComparator.isAscending() ^ previous) {
5622                                                    query.append(ORDER_BY_ASC);
5623                                            }
5624                                            else {
5625                                                    query.append(ORDER_BY_DESC);
5626                                            }
5627                                    }
5628                            }
5629                    }
5630                    else {
5631                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5632                    }
5633    
5634                    String sql = query.toString();
5635    
5636                    Query q = session.createQuery(sql);
5637    
5638                    q.setFirstResult(0);
5639                    q.setMaxResults(2);
5640    
5641                    QueryPos qPos = QueryPos.getInstance(q);
5642    
5643                    qPos.add(smallImageId);
5644    
5645                    if (orderByComparator != null) {
5646                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5647    
5648                            for (Object value : values) {
5649                                    qPos.add(value);
5650                            }
5651                    }
5652    
5653                    List<JournalArticle> list = q.list();
5654    
5655                    if (list.size() == 2) {
5656                            return list.get(1);
5657                    }
5658                    else {
5659                            return null;
5660                    }
5661            }
5662    
5663            /**
5664             * Removes all the journal articles where smallImageId = &#63; from the database.
5665             *
5666             * @param smallImageId the small image ID
5667             * @throws SystemException if a system exception occurred
5668             */
5669            @Override
5670            public void removeBySmallImageId(long smallImageId)
5671                    throws SystemException {
5672                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5673                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5674                            remove(journalArticle);
5675                    }
5676            }
5677    
5678            /**
5679             * Returns the number of journal articles where smallImageId = &#63;.
5680             *
5681             * @param smallImageId the small image ID
5682             * @return the number of matching journal articles
5683             * @throws SystemException if a system exception occurred
5684             */
5685            @Override
5686            public int countBySmallImageId(long smallImageId) throws SystemException {
5687                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5688    
5689                    Object[] finderArgs = new Object[] { smallImageId };
5690    
5691                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5692                                    this);
5693    
5694                    if (count == null) {
5695                            StringBundler query = new StringBundler(2);
5696    
5697                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5698    
5699                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5700    
5701                            String sql = query.toString();
5702    
5703                            Session session = null;
5704    
5705                            try {
5706                                    session = openSession();
5707    
5708                                    Query q = session.createQuery(sql);
5709    
5710                                    QueryPos qPos = QueryPos.getInstance(q);
5711    
5712                                    qPos.add(smallImageId);
5713    
5714                                    count = (Long)q.uniqueResult();
5715    
5716                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5717                            }
5718                            catch (Exception e) {
5719                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5720    
5721                                    throw processException(e);
5722                            }
5723                            finally {
5724                                    closeSession(session);
5725                            }
5726                    }
5727    
5728                    return count.intValue();
5729            }
5730    
5731            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5732            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5733                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5734                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5735                            "findByR_I",
5736                            new String[] {
5737                                    Long.class.getName(), Boolean.class.getName(),
5738                                    
5739                            Integer.class.getName(), Integer.class.getName(),
5740                                    OrderByComparator.class.getName()
5741                            });
5742            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5743                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5744                            JournalArticleImpl.class,
5745                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I",
5746                            new String[] { Long.class.getName(), Boolean.class.getName() },
5747                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5748                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
5749                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5750                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5751            public static final FinderPath FINDER_PATH_COUNT_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5752                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5753                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I",
5754                            new String[] { Long.class.getName(), Boolean.class.getName() });
5755    
5756            /**
5757             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5758             *
5759             * @param resourcePrimKey the resource prim key
5760             * @param indexable the indexable
5761             * @return the matching journal articles
5762             * @throws SystemException if a system exception occurred
5763             */
5764            @Override
5765            public List<JournalArticle> findByR_I(long resourcePrimKey,
5766                    boolean indexable) throws SystemException {
5767                    return findByR_I(resourcePrimKey, indexable, QueryUtil.ALL_POS,
5768                            QueryUtil.ALL_POS, null);
5769            }
5770    
5771            /**
5772             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5773             *
5774             * <p>
5775             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5776             * </p>
5777             *
5778             * @param resourcePrimKey the resource prim key
5779             * @param indexable the indexable
5780             * @param start the lower bound of the range of journal articles
5781             * @param end the upper bound of the range of journal articles (not inclusive)
5782             * @return the range of matching journal articles
5783             * @throws SystemException if a system exception occurred
5784             */
5785            @Override
5786            public List<JournalArticle> findByR_I(long resourcePrimKey,
5787                    boolean indexable, int start, int end) throws SystemException {
5788                    return findByR_I(resourcePrimKey, indexable, start, end, null);
5789            }
5790    
5791            /**
5792             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5793             *
5794             * <p>
5795             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5796             * </p>
5797             *
5798             * @param resourcePrimKey the resource prim key
5799             * @param indexable the indexable
5800             * @param start the lower bound of the range of journal articles
5801             * @param end the upper bound of the range of journal articles (not inclusive)
5802             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5803             * @return the ordered range of matching journal articles
5804             * @throws SystemException if a system exception occurred
5805             */
5806            @Override
5807            public List<JournalArticle> findByR_I(long resourcePrimKey,
5808                    boolean indexable, int start, int end,
5809                    OrderByComparator orderByComparator) throws SystemException {
5810                    boolean pagination = true;
5811                    FinderPath finderPath = null;
5812                    Object[] finderArgs = null;
5813    
5814                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5815                                    (orderByComparator == null)) {
5816                            pagination = false;
5817                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I;
5818                            finderArgs = new Object[] { resourcePrimKey, indexable };
5819                    }
5820                    else {
5821                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I;
5822                            finderArgs = new Object[] {
5823                                            resourcePrimKey, indexable,
5824                                            
5825                                            start, end, orderByComparator
5826                                    };
5827                    }
5828    
5829                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5830                                    finderArgs, this);
5831    
5832                    if ((list != null) && !list.isEmpty()) {
5833                            for (JournalArticle journalArticle : list) {
5834                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5835                                                    (indexable != journalArticle.getIndexable())) {
5836                                            list = null;
5837    
5838                                            break;
5839                                    }
5840                            }
5841                    }
5842    
5843                    if (list == null) {
5844                            StringBundler query = null;
5845    
5846                            if (orderByComparator != null) {
5847                                    query = new StringBundler(4 +
5848                                                    (orderByComparator.getOrderByFields().length * 3));
5849                            }
5850                            else {
5851                                    query = new StringBundler(4);
5852                            }
5853    
5854                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5855    
5856                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5857    
5858                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5859    
5860                            if (orderByComparator != null) {
5861                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5862                                            orderByComparator);
5863                            }
5864                            else
5865                             if (pagination) {
5866                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5867                            }
5868    
5869                            String sql = query.toString();
5870    
5871                            Session session = null;
5872    
5873                            try {
5874                                    session = openSession();
5875    
5876                                    Query q = session.createQuery(sql);
5877    
5878                                    QueryPos qPos = QueryPos.getInstance(q);
5879    
5880                                    qPos.add(resourcePrimKey);
5881    
5882                                    qPos.add(indexable);
5883    
5884                                    if (!pagination) {
5885                                            list = (List<JournalArticle>)QueryUtil.list(q,
5886                                                            getDialect(), start, end, false);
5887    
5888                                            Collections.sort(list);
5889    
5890                                            list = new UnmodifiableList<JournalArticle>(list);
5891                                    }
5892                                    else {
5893                                            list = (List<JournalArticle>)QueryUtil.list(q,
5894                                                            getDialect(), start, end);
5895                                    }
5896    
5897                                    cacheResult(list);
5898    
5899                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5900                            }
5901                            catch (Exception e) {
5902                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5903    
5904                                    throw processException(e);
5905                            }
5906                            finally {
5907                                    closeSession(session);
5908                            }
5909                    }
5910    
5911                    return list;
5912            }
5913    
5914            /**
5915             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5916             *
5917             * @param resourcePrimKey the resource prim key
5918             * @param indexable the indexable
5919             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5920             * @return the first matching journal article
5921             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5922             * @throws SystemException if a system exception occurred
5923             */
5924            @Override
5925            public JournalArticle findByR_I_First(long resourcePrimKey,
5926                    boolean indexable, OrderByComparator orderByComparator)
5927                    throws NoSuchArticleException, SystemException {
5928                    JournalArticle journalArticle = fetchByR_I_First(resourcePrimKey,
5929                                    indexable, orderByComparator);
5930    
5931                    if (journalArticle != null) {
5932                            return journalArticle;
5933                    }
5934    
5935                    StringBundler msg = new StringBundler(6);
5936    
5937                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5938    
5939                    msg.append("resourcePrimKey=");
5940                    msg.append(resourcePrimKey);
5941    
5942                    msg.append(", indexable=");
5943                    msg.append(indexable);
5944    
5945                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5946    
5947                    throw new NoSuchArticleException(msg.toString());
5948            }
5949    
5950            /**
5951             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5952             *
5953             * @param resourcePrimKey the resource prim key
5954             * @param indexable the indexable
5955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5956             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5957             * @throws SystemException if a system exception occurred
5958             */
5959            @Override
5960            public JournalArticle fetchByR_I_First(long resourcePrimKey,
5961                    boolean indexable, OrderByComparator orderByComparator)
5962                    throws SystemException {
5963                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable, 0, 1,
5964                                    orderByComparator);
5965    
5966                    if (!list.isEmpty()) {
5967                            return list.get(0);
5968                    }
5969    
5970                    return null;
5971            }
5972    
5973            /**
5974             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5975             *
5976             * @param resourcePrimKey the resource prim key
5977             * @param indexable the indexable
5978             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5979             * @return the last matching journal article
5980             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5981             * @throws SystemException if a system exception occurred
5982             */
5983            @Override
5984            public JournalArticle findByR_I_Last(long resourcePrimKey,
5985                    boolean indexable, OrderByComparator orderByComparator)
5986                    throws NoSuchArticleException, SystemException {
5987                    JournalArticle journalArticle = fetchByR_I_Last(resourcePrimKey,
5988                                    indexable, orderByComparator);
5989    
5990                    if (journalArticle != null) {
5991                            return journalArticle;
5992                    }
5993    
5994                    StringBundler msg = new StringBundler(6);
5995    
5996                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5997    
5998                    msg.append("resourcePrimKey=");
5999                    msg.append(resourcePrimKey);
6000    
6001                    msg.append(", indexable=");
6002                    msg.append(indexable);
6003    
6004                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6005    
6006                    throw new NoSuchArticleException(msg.toString());
6007            }
6008    
6009            /**
6010             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6011             *
6012             * @param resourcePrimKey the resource prim key
6013             * @param indexable the indexable
6014             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6015             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6016             * @throws SystemException if a system exception occurred
6017             */
6018            @Override
6019            public JournalArticle fetchByR_I_Last(long resourcePrimKey,
6020                    boolean indexable, OrderByComparator orderByComparator)
6021                    throws SystemException {
6022                    int count = countByR_I(resourcePrimKey, indexable);
6023    
6024                    if (count == 0) {
6025                            return null;
6026                    }
6027    
6028                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable,
6029                                    count - 1, count, orderByComparator);
6030    
6031                    if (!list.isEmpty()) {
6032                            return list.get(0);
6033                    }
6034    
6035                    return null;
6036            }
6037    
6038            /**
6039             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6040             *
6041             * @param id the primary key of the current journal article
6042             * @param resourcePrimKey the resource prim key
6043             * @param indexable the indexable
6044             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6045             * @return the previous, current, and next journal article
6046             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6047             * @throws SystemException if a system exception occurred
6048             */
6049            @Override
6050            public JournalArticle[] findByR_I_PrevAndNext(long id,
6051                    long resourcePrimKey, boolean indexable,
6052                    OrderByComparator orderByComparator)
6053                    throws NoSuchArticleException, SystemException {
6054                    JournalArticle journalArticle = findByPrimaryKey(id);
6055    
6056                    Session session = null;
6057    
6058                    try {
6059                            session = openSession();
6060    
6061                            JournalArticle[] array = new JournalArticleImpl[3];
6062    
6063                            array[0] = getByR_I_PrevAndNext(session, journalArticle,
6064                                            resourcePrimKey, indexable, orderByComparator, true);
6065    
6066                            array[1] = journalArticle;
6067    
6068                            array[2] = getByR_I_PrevAndNext(session, journalArticle,
6069                                            resourcePrimKey, indexable, orderByComparator, false);
6070    
6071                            return array;
6072                    }
6073                    catch (Exception e) {
6074                            throw processException(e);
6075                    }
6076                    finally {
6077                            closeSession(session);
6078                    }
6079            }
6080    
6081            protected JournalArticle getByR_I_PrevAndNext(Session session,
6082                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
6083                    OrderByComparator orderByComparator, boolean previous) {
6084                    StringBundler query = null;
6085    
6086                    if (orderByComparator != null) {
6087                            query = new StringBundler(6 +
6088                                            (orderByComparator.getOrderByFields().length * 6));
6089                    }
6090                    else {
6091                            query = new StringBundler(3);
6092                    }
6093    
6094                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6095    
6096                    query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6097    
6098                    query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6099    
6100                    if (orderByComparator != null) {
6101                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6102    
6103                            if (orderByConditionFields.length > 0) {
6104                                    query.append(WHERE_AND);
6105                            }
6106    
6107                            for (int i = 0; i < orderByConditionFields.length; i++) {
6108                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6109                                    query.append(orderByConditionFields[i]);
6110    
6111                                    if ((i + 1) < orderByConditionFields.length) {
6112                                            if (orderByComparator.isAscending() ^ previous) {
6113                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6114                                            }
6115                                            else {
6116                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6117                                            }
6118                                    }
6119                                    else {
6120                                            if (orderByComparator.isAscending() ^ previous) {
6121                                                    query.append(WHERE_GREATER_THAN);
6122                                            }
6123                                            else {
6124                                                    query.append(WHERE_LESSER_THAN);
6125                                            }
6126                                    }
6127                            }
6128    
6129                            query.append(ORDER_BY_CLAUSE);
6130    
6131                            String[] orderByFields = orderByComparator.getOrderByFields();
6132    
6133                            for (int i = 0; i < orderByFields.length; i++) {
6134                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6135                                    query.append(orderByFields[i]);
6136    
6137                                    if ((i + 1) < orderByFields.length) {
6138                                            if (orderByComparator.isAscending() ^ previous) {
6139                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6140                                            }
6141                                            else {
6142                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6143                                            }
6144                                    }
6145                                    else {
6146                                            if (orderByComparator.isAscending() ^ previous) {
6147                                                    query.append(ORDER_BY_ASC);
6148                                            }
6149                                            else {
6150                                                    query.append(ORDER_BY_DESC);
6151                                            }
6152                                    }
6153                            }
6154                    }
6155                    else {
6156                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6157                    }
6158    
6159                    String sql = query.toString();
6160    
6161                    Query q = session.createQuery(sql);
6162    
6163                    q.setFirstResult(0);
6164                    q.setMaxResults(2);
6165    
6166                    QueryPos qPos = QueryPos.getInstance(q);
6167    
6168                    qPos.add(resourcePrimKey);
6169    
6170                    qPos.add(indexable);
6171    
6172                    if (orderByComparator != null) {
6173                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6174    
6175                            for (Object value : values) {
6176                                    qPos.add(value);
6177                            }
6178                    }
6179    
6180                    List<JournalArticle> list = q.list();
6181    
6182                    if (list.size() == 2) {
6183                            return list.get(1);
6184                    }
6185                    else {
6186                            return null;
6187                    }
6188            }
6189    
6190            /**
6191             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; from the database.
6192             *
6193             * @param resourcePrimKey the resource prim key
6194             * @param indexable the indexable
6195             * @throws SystemException if a system exception occurred
6196             */
6197            @Override
6198            public void removeByR_I(long resourcePrimKey, boolean indexable)
6199                    throws SystemException {
6200                    for (JournalArticle journalArticle : findByR_I(resourcePrimKey,
6201                                    indexable, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6202                            remove(journalArticle);
6203                    }
6204            }
6205    
6206            /**
6207             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63;.
6208             *
6209             * @param resourcePrimKey the resource prim key
6210             * @param indexable the indexable
6211             * @return the number of matching journal articles
6212             * @throws SystemException if a system exception occurred
6213             */
6214            @Override
6215            public int countByR_I(long resourcePrimKey, boolean indexable)
6216                    throws SystemException {
6217                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I;
6218    
6219                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable };
6220    
6221                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6222                                    this);
6223    
6224                    if (count == null) {
6225                            StringBundler query = new StringBundler(3);
6226    
6227                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6228    
6229                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6230    
6231                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6232    
6233                            String sql = query.toString();
6234    
6235                            Session session = null;
6236    
6237                            try {
6238                                    session = openSession();
6239    
6240                                    Query q = session.createQuery(sql);
6241    
6242                                    QueryPos qPos = QueryPos.getInstance(q);
6243    
6244                                    qPos.add(resourcePrimKey);
6245    
6246                                    qPos.add(indexable);
6247    
6248                                    count = (Long)q.uniqueResult();
6249    
6250                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6251                            }
6252                            catch (Exception e) {
6253                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6254    
6255                                    throw processException(e);
6256                            }
6257                            finally {
6258                                    closeSession(session);
6259                            }
6260                    }
6261    
6262                    return count.intValue();
6263            }
6264    
6265            private static final String _FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6266            private static final String _FINDER_COLUMN_R_I_INDEXABLE_2 = "journalArticle.indexable = ?";
6267            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6268                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6269                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6270                            "findByR_ST",
6271                            new String[] {
6272                                    Long.class.getName(), Integer.class.getName(),
6273                                    
6274                            Integer.class.getName(), Integer.class.getName(),
6275                                    OrderByComparator.class.getName()
6276                            });
6277            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6278                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6279                            JournalArticleImpl.class,
6280                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
6281                            new String[] { Long.class.getName(), Integer.class.getName() },
6282                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6283                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
6284                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6285                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6286            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6287                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6288                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
6289                            new String[] { Long.class.getName(), Integer.class.getName() });
6290    
6291            /**
6292             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6293             *
6294             * @param resourcePrimKey the resource prim key
6295             * @param status the status
6296             * @return the matching journal articles
6297             * @throws SystemException if a system exception occurred
6298             */
6299            @Override
6300            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
6301                    throws SystemException {
6302                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
6303                            QueryUtil.ALL_POS, null);
6304            }
6305    
6306            /**
6307             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6308             *
6309             * <p>
6310             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6311             * </p>
6312             *
6313             * @param resourcePrimKey the resource prim key
6314             * @param status the status
6315             * @param start the lower bound of the range of journal articles
6316             * @param end the upper bound of the range of journal articles (not inclusive)
6317             * @return the range of matching journal articles
6318             * @throws SystemException if a system exception occurred
6319             */
6320            @Override
6321            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6322                    int start, int end) throws SystemException {
6323                    return findByR_ST(resourcePrimKey, status, start, end, null);
6324            }
6325    
6326            /**
6327             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6328             *
6329             * <p>
6330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6331             * </p>
6332             *
6333             * @param resourcePrimKey the resource prim key
6334             * @param status the status
6335             * @param start the lower bound of the range of journal articles
6336             * @param end the upper bound of the range of journal articles (not inclusive)
6337             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6338             * @return the ordered range of matching journal articles
6339             * @throws SystemException if a system exception occurred
6340             */
6341            @Override
6342            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6343                    int start, int end, OrderByComparator orderByComparator)
6344                    throws SystemException {
6345                    boolean pagination = true;
6346                    FinderPath finderPath = null;
6347                    Object[] finderArgs = null;
6348    
6349                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6350                                    (orderByComparator == null)) {
6351                            pagination = false;
6352                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
6353                            finderArgs = new Object[] { resourcePrimKey, status };
6354                    }
6355                    else {
6356                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
6357                            finderArgs = new Object[] {
6358                                            resourcePrimKey, status,
6359                                            
6360                                            start, end, orderByComparator
6361                                    };
6362                    }
6363    
6364                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6365                                    finderArgs, this);
6366    
6367                    if ((list != null) && !list.isEmpty()) {
6368                            for (JournalArticle journalArticle : list) {
6369                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6370                                                    (status != journalArticle.getStatus())) {
6371                                            list = null;
6372    
6373                                            break;
6374                                    }
6375                            }
6376                    }
6377    
6378                    if (list == null) {
6379                            StringBundler query = null;
6380    
6381                            if (orderByComparator != null) {
6382                                    query = new StringBundler(4 +
6383                                                    (orderByComparator.getOrderByFields().length * 3));
6384                            }
6385                            else {
6386                                    query = new StringBundler(4);
6387                            }
6388    
6389                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6390    
6391                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6392    
6393                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6394    
6395                            if (orderByComparator != null) {
6396                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6397                                            orderByComparator);
6398                            }
6399                            else
6400                             if (pagination) {
6401                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6402                            }
6403    
6404                            String sql = query.toString();
6405    
6406                            Session session = null;
6407    
6408                            try {
6409                                    session = openSession();
6410    
6411                                    Query q = session.createQuery(sql);
6412    
6413                                    QueryPos qPos = QueryPos.getInstance(q);
6414    
6415                                    qPos.add(resourcePrimKey);
6416    
6417                                    qPos.add(status);
6418    
6419                                    if (!pagination) {
6420                                            list = (List<JournalArticle>)QueryUtil.list(q,
6421                                                            getDialect(), start, end, false);
6422    
6423                                            Collections.sort(list);
6424    
6425                                            list = new UnmodifiableList<JournalArticle>(list);
6426                                    }
6427                                    else {
6428                                            list = (List<JournalArticle>)QueryUtil.list(q,
6429                                                            getDialect(), start, end);
6430                                    }
6431    
6432                                    cacheResult(list);
6433    
6434                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6435                            }
6436                            catch (Exception e) {
6437                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6438    
6439                                    throw processException(e);
6440                            }
6441                            finally {
6442                                    closeSession(session);
6443                            }
6444                    }
6445    
6446                    return list;
6447            }
6448    
6449            /**
6450             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6451             *
6452             * @param resourcePrimKey the resource prim key
6453             * @param status the status
6454             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6455             * @return the first matching journal article
6456             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6457             * @throws SystemException if a system exception occurred
6458             */
6459            @Override
6460            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
6461                    OrderByComparator orderByComparator)
6462                    throws NoSuchArticleException, SystemException {
6463                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
6464                                    status, orderByComparator);
6465    
6466                    if (journalArticle != null) {
6467                            return journalArticle;
6468                    }
6469    
6470                    StringBundler msg = new StringBundler(6);
6471    
6472                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6473    
6474                    msg.append("resourcePrimKey=");
6475                    msg.append(resourcePrimKey);
6476    
6477                    msg.append(", status=");
6478                    msg.append(status);
6479    
6480                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6481    
6482                    throw new NoSuchArticleException(msg.toString());
6483            }
6484    
6485            /**
6486             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6487             *
6488             * @param resourcePrimKey the resource prim key
6489             * @param status the status
6490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6491             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6492             * @throws SystemException if a system exception occurred
6493             */
6494            @Override
6495            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
6496                    OrderByComparator orderByComparator) throws SystemException {
6497                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
6498                                    orderByComparator);
6499    
6500                    if (!list.isEmpty()) {
6501                            return list.get(0);
6502                    }
6503    
6504                    return null;
6505            }
6506    
6507            /**
6508             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6509             *
6510             * @param resourcePrimKey the resource prim key
6511             * @param status the status
6512             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6513             * @return the last matching journal article
6514             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6515             * @throws SystemException if a system exception occurred
6516             */
6517            @Override
6518            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
6519                    OrderByComparator orderByComparator)
6520                    throws NoSuchArticleException, SystemException {
6521                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
6522                                    status, orderByComparator);
6523    
6524                    if (journalArticle != null) {
6525                            return journalArticle;
6526                    }
6527    
6528                    StringBundler msg = new StringBundler(6);
6529    
6530                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6531    
6532                    msg.append("resourcePrimKey=");
6533                    msg.append(resourcePrimKey);
6534    
6535                    msg.append(", status=");
6536                    msg.append(status);
6537    
6538                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6539    
6540                    throw new NoSuchArticleException(msg.toString());
6541            }
6542    
6543            /**
6544             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6545             *
6546             * @param resourcePrimKey the resource prim key
6547             * @param status the status
6548             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6549             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6550             * @throws SystemException if a system exception occurred
6551             */
6552            @Override
6553            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6554                    OrderByComparator orderByComparator) throws SystemException {
6555                    int count = countByR_ST(resourcePrimKey, status);
6556    
6557                    if (count == 0) {
6558                            return null;
6559                    }
6560    
6561                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6562                                    count - 1, count, orderByComparator);
6563    
6564                    if (!list.isEmpty()) {
6565                            return list.get(0);
6566                    }
6567    
6568                    return null;
6569            }
6570    
6571            /**
6572             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6573             *
6574             * @param id the primary key of the current journal article
6575             * @param resourcePrimKey the resource prim key
6576             * @param status the status
6577             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6578             * @return the previous, current, and next journal article
6579             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6580             * @throws SystemException if a system exception occurred
6581             */
6582            @Override
6583            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6584                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
6585                    throws NoSuchArticleException, SystemException {
6586                    JournalArticle journalArticle = findByPrimaryKey(id);
6587    
6588                    Session session = null;
6589    
6590                    try {
6591                            session = openSession();
6592    
6593                            JournalArticle[] array = new JournalArticleImpl[3];
6594    
6595                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6596                                            resourcePrimKey, status, orderByComparator, true);
6597    
6598                            array[1] = journalArticle;
6599    
6600                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6601                                            resourcePrimKey, status, orderByComparator, false);
6602    
6603                            return array;
6604                    }
6605                    catch (Exception e) {
6606                            throw processException(e);
6607                    }
6608                    finally {
6609                            closeSession(session);
6610                    }
6611            }
6612    
6613            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6614                    JournalArticle journalArticle, long resourcePrimKey, int status,
6615                    OrderByComparator orderByComparator, boolean previous) {
6616                    StringBundler query = null;
6617    
6618                    if (orderByComparator != null) {
6619                            query = new StringBundler(6 +
6620                                            (orderByComparator.getOrderByFields().length * 6));
6621                    }
6622                    else {
6623                            query = new StringBundler(3);
6624                    }
6625    
6626                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6627    
6628                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6629    
6630                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6631    
6632                    if (orderByComparator != null) {
6633                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6634    
6635                            if (orderByConditionFields.length > 0) {
6636                                    query.append(WHERE_AND);
6637                            }
6638    
6639                            for (int i = 0; i < orderByConditionFields.length; i++) {
6640                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6641                                    query.append(orderByConditionFields[i]);
6642    
6643                                    if ((i + 1) < orderByConditionFields.length) {
6644                                            if (orderByComparator.isAscending() ^ previous) {
6645                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6646                                            }
6647                                            else {
6648                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6649                                            }
6650                                    }
6651                                    else {
6652                                            if (orderByComparator.isAscending() ^ previous) {
6653                                                    query.append(WHERE_GREATER_THAN);
6654                                            }
6655                                            else {
6656                                                    query.append(WHERE_LESSER_THAN);
6657                                            }
6658                                    }
6659                            }
6660    
6661                            query.append(ORDER_BY_CLAUSE);
6662    
6663                            String[] orderByFields = orderByComparator.getOrderByFields();
6664    
6665                            for (int i = 0; i < orderByFields.length; i++) {
6666                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6667                                    query.append(orderByFields[i]);
6668    
6669                                    if ((i + 1) < orderByFields.length) {
6670                                            if (orderByComparator.isAscending() ^ previous) {
6671                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6672                                            }
6673                                            else {
6674                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6675                                            }
6676                                    }
6677                                    else {
6678                                            if (orderByComparator.isAscending() ^ previous) {
6679                                                    query.append(ORDER_BY_ASC);
6680                                            }
6681                                            else {
6682                                                    query.append(ORDER_BY_DESC);
6683                                            }
6684                                    }
6685                            }
6686                    }
6687                    else {
6688                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6689                    }
6690    
6691                    String sql = query.toString();
6692    
6693                    Query q = session.createQuery(sql);
6694    
6695                    q.setFirstResult(0);
6696                    q.setMaxResults(2);
6697    
6698                    QueryPos qPos = QueryPos.getInstance(q);
6699    
6700                    qPos.add(resourcePrimKey);
6701    
6702                    qPos.add(status);
6703    
6704                    if (orderByComparator != null) {
6705                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6706    
6707                            for (Object value : values) {
6708                                    qPos.add(value);
6709                            }
6710                    }
6711    
6712                    List<JournalArticle> list = q.list();
6713    
6714                    if (list.size() == 2) {
6715                            return list.get(1);
6716                    }
6717                    else {
6718                            return null;
6719                    }
6720            }
6721    
6722            /**
6723             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6724             *
6725             * @param resourcePrimKey the resource prim key
6726             * @param status the status
6727             * @throws SystemException if a system exception occurred
6728             */
6729            @Override
6730            public void removeByR_ST(long resourcePrimKey, int status)
6731                    throws SystemException {
6732                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6733                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6734                            remove(journalArticle);
6735                    }
6736            }
6737    
6738            /**
6739             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6740             *
6741             * @param resourcePrimKey the resource prim key
6742             * @param status the status
6743             * @return the number of matching journal articles
6744             * @throws SystemException if a system exception occurred
6745             */
6746            @Override
6747            public int countByR_ST(long resourcePrimKey, int status)
6748                    throws SystemException {
6749                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6750    
6751                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6752    
6753                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6754                                    this);
6755    
6756                    if (count == null) {
6757                            StringBundler query = new StringBundler(3);
6758    
6759                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6760    
6761                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6762    
6763                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6764    
6765                            String sql = query.toString();
6766    
6767                            Session session = null;
6768    
6769                            try {
6770                                    session = openSession();
6771    
6772                                    Query q = session.createQuery(sql);
6773    
6774                                    QueryPos qPos = QueryPos.getInstance(q);
6775    
6776                                    qPos.add(resourcePrimKey);
6777    
6778                                    qPos.add(status);
6779    
6780                                    count = (Long)q.uniqueResult();
6781    
6782                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6783                            }
6784                            catch (Exception e) {
6785                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6786    
6787                                    throw processException(e);
6788                            }
6789                            finally {
6790                                    closeSession(session);
6791                            }
6792                    }
6793    
6794                    return count.intValue();
6795            }
6796    
6797            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6798            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
6799            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6800                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6801                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6802                            "findByG_U",
6803                            new String[] {
6804                                    Long.class.getName(), Long.class.getName(),
6805                                    
6806                            Integer.class.getName(), Integer.class.getName(),
6807                                    OrderByComparator.class.getName()
6808                            });
6809            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6810                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6811                            JournalArticleImpl.class,
6812                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
6813                            new String[] { Long.class.getName(), Long.class.getName() },
6814                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
6815                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
6816                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6817                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6818            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6819                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6820                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
6821                            new String[] { Long.class.getName(), Long.class.getName() });
6822    
6823            /**
6824             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
6825             *
6826             * @param groupId the group ID
6827             * @param userId the user ID
6828             * @return the matching journal articles
6829             * @throws SystemException if a system exception occurred
6830             */
6831            @Override
6832            public List<JournalArticle> findByG_U(long groupId, long userId)
6833                    throws SystemException {
6834                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6835                            null);
6836            }
6837    
6838            /**
6839             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
6840             *
6841             * <p>
6842             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6843             * </p>
6844             *
6845             * @param groupId the group ID
6846             * @param userId the user ID
6847             * @param start the lower bound of the range of journal articles
6848             * @param end the upper bound of the range of journal articles (not inclusive)
6849             * @return the range of matching journal articles
6850             * @throws SystemException if a system exception occurred
6851             */
6852            @Override
6853            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6854                    int end) throws SystemException {
6855                    return findByG_U(groupId, userId, start, end, null);
6856            }
6857    
6858            /**
6859             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
6860             *
6861             * <p>
6862             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6863             * </p>
6864             *
6865             * @param groupId the group ID
6866             * @param userId the user ID
6867             * @param start the lower bound of the range of journal articles
6868             * @param end the upper bound of the range of journal articles (not inclusive)
6869             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6870             * @return the ordered range of matching journal articles
6871             * @throws SystemException if a system exception occurred
6872             */
6873            @Override
6874            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6875                    int end, OrderByComparator orderByComparator) throws SystemException {
6876                    boolean pagination = true;
6877                    FinderPath finderPath = null;
6878                    Object[] finderArgs = null;
6879    
6880                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6881                                    (orderByComparator == null)) {
6882                            pagination = false;
6883                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
6884                            finderArgs = new Object[] { groupId, userId };
6885                    }
6886                    else {
6887                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
6888                            finderArgs = new Object[] {
6889                                            groupId, userId,
6890                                            
6891                                            start, end, orderByComparator
6892                                    };
6893                    }
6894    
6895                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6896                                    finderArgs, this);
6897    
6898                    if ((list != null) && !list.isEmpty()) {
6899                            for (JournalArticle journalArticle : list) {
6900                                    if ((groupId != journalArticle.getGroupId()) ||
6901                                                    (userId != journalArticle.getUserId())) {
6902                                            list = null;
6903    
6904                                            break;
6905                                    }
6906                            }
6907                    }
6908    
6909                    if (list == null) {
6910                            StringBundler query = null;
6911    
6912                            if (orderByComparator != null) {
6913                                    query = new StringBundler(4 +
6914                                                    (orderByComparator.getOrderByFields().length * 3));
6915                            }
6916                            else {
6917                                    query = new StringBundler(4);
6918                            }
6919    
6920                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6921    
6922                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6923    
6924                            query.append(_FINDER_COLUMN_G_U_USERID_2);
6925    
6926                            if (orderByComparator != null) {
6927                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6928                                            orderByComparator);
6929                            }
6930                            else
6931                             if (pagination) {
6932                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6933                            }
6934    
6935                            String sql = query.toString();
6936    
6937                            Session session = null;
6938    
6939                            try {
6940                                    session = openSession();
6941    
6942                                    Query q = session.createQuery(sql);
6943    
6944                                    QueryPos qPos = QueryPos.getInstance(q);
6945    
6946                                    qPos.add(groupId);
6947    
6948                                    qPos.add(userId);
6949    
6950                                    if (!pagination) {
6951                                            list = (List<JournalArticle>)QueryUtil.list(q,
6952                                                            getDialect(), start, end, false);
6953    
6954                                            Collections.sort(list);
6955    
6956                                            list = new UnmodifiableList<JournalArticle>(list);
6957                                    }
6958                                    else {
6959                                            list = (List<JournalArticle>)QueryUtil.list(q,
6960                                                            getDialect(), start, end);
6961                                    }
6962    
6963                                    cacheResult(list);
6964    
6965                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6966                            }
6967                            catch (Exception e) {
6968                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6969    
6970                                    throw processException(e);
6971                            }
6972                            finally {
6973                                    closeSession(session);
6974                            }
6975                    }
6976    
6977                    return list;
6978            }
6979    
6980            /**
6981             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6982             *
6983             * @param groupId the group ID
6984             * @param userId the user ID
6985             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6986             * @return the first matching journal article
6987             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6988             * @throws SystemException if a system exception occurred
6989             */
6990            @Override
6991            public JournalArticle findByG_U_First(long groupId, long userId,
6992                    OrderByComparator orderByComparator)
6993                    throws NoSuchArticleException, SystemException {
6994                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
6995                                    orderByComparator);
6996    
6997                    if (journalArticle != null) {
6998                            return journalArticle;
6999                    }
7000    
7001                    StringBundler msg = new StringBundler(6);
7002    
7003                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7004    
7005                    msg.append("groupId=");
7006                    msg.append(groupId);
7007    
7008                    msg.append(", userId=");
7009                    msg.append(userId);
7010    
7011                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7012    
7013                    throw new NoSuchArticleException(msg.toString());
7014            }
7015    
7016            /**
7017             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7018             *
7019             * @param groupId the group ID
7020             * @param userId the user ID
7021             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7022             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7023             * @throws SystemException if a system exception occurred
7024             */
7025            @Override
7026            public JournalArticle fetchByG_U_First(long groupId, long userId,
7027                    OrderByComparator orderByComparator) throws SystemException {
7028                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
7029                                    orderByComparator);
7030    
7031                    if (!list.isEmpty()) {
7032                            return list.get(0);
7033                    }
7034    
7035                    return null;
7036            }
7037    
7038            /**
7039             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7040             *
7041             * @param groupId the group ID
7042             * @param userId the user ID
7043             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7044             * @return the last matching journal article
7045             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7046             * @throws SystemException if a system exception occurred
7047             */
7048            @Override
7049            public JournalArticle findByG_U_Last(long groupId, long userId,
7050                    OrderByComparator orderByComparator)
7051                    throws NoSuchArticleException, SystemException {
7052                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
7053                                    orderByComparator);
7054    
7055                    if (journalArticle != null) {
7056                            return journalArticle;
7057                    }
7058    
7059                    StringBundler msg = new StringBundler(6);
7060    
7061                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7062    
7063                    msg.append("groupId=");
7064                    msg.append(groupId);
7065    
7066                    msg.append(", userId=");
7067                    msg.append(userId);
7068    
7069                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7070    
7071                    throw new NoSuchArticleException(msg.toString());
7072            }
7073    
7074            /**
7075             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7076             *
7077             * @param groupId the group ID
7078             * @param userId the user ID
7079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7080             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7081             * @throws SystemException if a system exception occurred
7082             */
7083            @Override
7084            public JournalArticle fetchByG_U_Last(long groupId, long userId,
7085                    OrderByComparator orderByComparator) throws SystemException {
7086                    int count = countByG_U(groupId, userId);
7087    
7088                    if (count == 0) {
7089                            return null;
7090                    }
7091    
7092                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
7093                                    count, orderByComparator);
7094    
7095                    if (!list.isEmpty()) {
7096                            return list.get(0);
7097                    }
7098    
7099                    return null;
7100            }
7101    
7102            /**
7103             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
7104             *
7105             * @param id the primary key of the current journal article
7106             * @param groupId the group ID
7107             * @param userId the user ID
7108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7109             * @return the previous, current, and next journal article
7110             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7111             * @throws SystemException if a system exception occurred
7112             */
7113            @Override
7114            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
7115                    long userId, OrderByComparator orderByComparator)
7116                    throws NoSuchArticleException, SystemException {
7117                    JournalArticle journalArticle = findByPrimaryKey(id);
7118    
7119                    Session session = null;
7120    
7121                    try {
7122                            session = openSession();
7123    
7124                            JournalArticle[] array = new JournalArticleImpl[3];
7125    
7126                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7127                                            userId, orderByComparator, true);
7128    
7129                            array[1] = journalArticle;
7130    
7131                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7132                                            userId, orderByComparator, false);
7133    
7134                            return array;
7135                    }
7136                    catch (Exception e) {
7137                            throw processException(e);
7138                    }
7139                    finally {
7140                            closeSession(session);
7141                    }
7142            }
7143    
7144            protected JournalArticle getByG_U_PrevAndNext(Session session,
7145                    JournalArticle journalArticle, long groupId, long userId,
7146                    OrderByComparator orderByComparator, boolean previous) {
7147                    StringBundler query = null;
7148    
7149                    if (orderByComparator != null) {
7150                            query = new StringBundler(6 +
7151                                            (orderByComparator.getOrderByFields().length * 6));
7152                    }
7153                    else {
7154                            query = new StringBundler(3);
7155                    }
7156    
7157                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7158    
7159                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7160    
7161                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7162    
7163                    if (orderByComparator != null) {
7164                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7165    
7166                            if (orderByConditionFields.length > 0) {
7167                                    query.append(WHERE_AND);
7168                            }
7169    
7170                            for (int i = 0; i < orderByConditionFields.length; i++) {
7171                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7172                                    query.append(orderByConditionFields[i]);
7173    
7174                                    if ((i + 1) < orderByConditionFields.length) {
7175                                            if (orderByComparator.isAscending() ^ previous) {
7176                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7177                                            }
7178                                            else {
7179                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7180                                            }
7181                                    }
7182                                    else {
7183                                            if (orderByComparator.isAscending() ^ previous) {
7184                                                    query.append(WHERE_GREATER_THAN);
7185                                            }
7186                                            else {
7187                                                    query.append(WHERE_LESSER_THAN);
7188                                            }
7189                                    }
7190                            }
7191    
7192                            query.append(ORDER_BY_CLAUSE);
7193    
7194                            String[] orderByFields = orderByComparator.getOrderByFields();
7195    
7196                            for (int i = 0; i < orderByFields.length; i++) {
7197                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7198                                    query.append(orderByFields[i]);
7199    
7200                                    if ((i + 1) < orderByFields.length) {
7201                                            if (orderByComparator.isAscending() ^ previous) {
7202                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7203                                            }
7204                                            else {
7205                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7206                                            }
7207                                    }
7208                                    else {
7209                                            if (orderByComparator.isAscending() ^ previous) {
7210                                                    query.append(ORDER_BY_ASC);
7211                                            }
7212                                            else {
7213                                                    query.append(ORDER_BY_DESC);
7214                                            }
7215                                    }
7216                            }
7217                    }
7218                    else {
7219                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7220                    }
7221    
7222                    String sql = query.toString();
7223    
7224                    Query q = session.createQuery(sql);
7225    
7226                    q.setFirstResult(0);
7227                    q.setMaxResults(2);
7228    
7229                    QueryPos qPos = QueryPos.getInstance(q);
7230    
7231                    qPos.add(groupId);
7232    
7233                    qPos.add(userId);
7234    
7235                    if (orderByComparator != null) {
7236                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7237    
7238                            for (Object value : values) {
7239                                    qPos.add(value);
7240                            }
7241                    }
7242    
7243                    List<JournalArticle> list = q.list();
7244    
7245                    if (list.size() == 2) {
7246                            return list.get(1);
7247                    }
7248                    else {
7249                            return null;
7250                    }
7251            }
7252    
7253            /**
7254             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7255             *
7256             * @param groupId the group ID
7257             * @param userId the user ID
7258             * @return the matching journal articles that the user has permission to view
7259             * @throws SystemException if a system exception occurred
7260             */
7261            @Override
7262            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
7263                    throws SystemException {
7264                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
7265                            QueryUtil.ALL_POS, null);
7266            }
7267    
7268            /**
7269             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7270             *
7271             * <p>
7272             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7273             * </p>
7274             *
7275             * @param groupId the group ID
7276             * @param userId the user ID
7277             * @param start the lower bound of the range of journal articles
7278             * @param end the upper bound of the range of journal articles (not inclusive)
7279             * @return the range of matching journal articles that the user has permission to view
7280             * @throws SystemException if a system exception occurred
7281             */
7282            @Override
7283            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7284                    int start, int end) throws SystemException {
7285                    return filterFindByG_U(groupId, userId, start, end, null);
7286            }
7287    
7288            /**
7289             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
7290             *
7291             * <p>
7292             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7293             * </p>
7294             *
7295             * @param groupId the group ID
7296             * @param userId the user ID
7297             * @param start the lower bound of the range of journal articles
7298             * @param end the upper bound of the range of journal articles (not inclusive)
7299             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7300             * @return the ordered range of matching journal articles that the user has permission to view
7301             * @throws SystemException if a system exception occurred
7302             */
7303            @Override
7304            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7305                    int start, int end, OrderByComparator orderByComparator)
7306                    throws SystemException {
7307                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7308                            return findByG_U(groupId, userId, start, end, orderByComparator);
7309                    }
7310    
7311                    StringBundler query = null;
7312    
7313                    if (orderByComparator != null) {
7314                            query = new StringBundler(4 +
7315                                            (orderByComparator.getOrderByFields().length * 3));
7316                    }
7317                    else {
7318                            query = new StringBundler(4);
7319                    }
7320    
7321                    if (getDB().isSupportsInlineDistinct()) {
7322                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7323                    }
7324                    else {
7325                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7326                    }
7327    
7328                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7329    
7330                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7331    
7332                    if (!getDB().isSupportsInlineDistinct()) {
7333                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7334                    }
7335    
7336                    if (orderByComparator != null) {
7337                            if (getDB().isSupportsInlineDistinct()) {
7338                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7339                                            orderByComparator, true);
7340                            }
7341                            else {
7342                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7343                                            orderByComparator, true);
7344                            }
7345                    }
7346                    else {
7347                            if (getDB().isSupportsInlineDistinct()) {
7348                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7349                            }
7350                            else {
7351                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7352                            }
7353                    }
7354    
7355                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7356                                    JournalArticle.class.getName(),
7357                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7358    
7359                    Session session = null;
7360    
7361                    try {
7362                            session = openSession();
7363    
7364                            SQLQuery q = session.createSQLQuery(sql);
7365    
7366                            if (getDB().isSupportsInlineDistinct()) {
7367                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7368                            }
7369                            else {
7370                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7371                            }
7372    
7373                            QueryPos qPos = QueryPos.getInstance(q);
7374    
7375                            qPos.add(groupId);
7376    
7377                            qPos.add(userId);
7378    
7379                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7380                                    end);
7381                    }
7382                    catch (Exception e) {
7383                            throw processException(e);
7384                    }
7385                    finally {
7386                            closeSession(session);
7387                    }
7388            }
7389    
7390            /**
7391             * 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;.
7392             *
7393             * @param id the primary key of the current journal article
7394             * @param groupId the group ID
7395             * @param userId the user ID
7396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7397             * @return the previous, current, and next journal article
7398             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7399             * @throws SystemException if a system exception occurred
7400             */
7401            @Override
7402            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
7403                    long userId, OrderByComparator orderByComparator)
7404                    throws NoSuchArticleException, SystemException {
7405                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7406                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
7407                    }
7408    
7409                    JournalArticle journalArticle = findByPrimaryKey(id);
7410    
7411                    Session session = null;
7412    
7413                    try {
7414                            session = openSession();
7415    
7416                            JournalArticle[] array = new JournalArticleImpl[3];
7417    
7418                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
7419                                            groupId, userId, orderByComparator, true);
7420    
7421                            array[1] = journalArticle;
7422    
7423                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
7424                                            groupId, userId, orderByComparator, false);
7425    
7426                            return array;
7427                    }
7428                    catch (Exception e) {
7429                            throw processException(e);
7430                    }
7431                    finally {
7432                            closeSession(session);
7433                    }
7434            }
7435    
7436            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
7437                    JournalArticle journalArticle, long groupId, long userId,
7438                    OrderByComparator orderByComparator, boolean previous) {
7439                    StringBundler query = null;
7440    
7441                    if (orderByComparator != null) {
7442                            query = new StringBundler(6 +
7443                                            (orderByComparator.getOrderByFields().length * 6));
7444                    }
7445                    else {
7446                            query = new StringBundler(3);
7447                    }
7448    
7449                    if (getDB().isSupportsInlineDistinct()) {
7450                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7451                    }
7452                    else {
7453                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7454                    }
7455    
7456                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7457    
7458                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7459    
7460                    if (!getDB().isSupportsInlineDistinct()) {
7461                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7462                    }
7463    
7464                    if (orderByComparator != null) {
7465                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7466    
7467                            if (orderByConditionFields.length > 0) {
7468                                    query.append(WHERE_AND);
7469                            }
7470    
7471                            for (int i = 0; i < orderByConditionFields.length; i++) {
7472                                    if (getDB().isSupportsInlineDistinct()) {
7473                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7474                                    }
7475                                    else {
7476                                            query.append(_ORDER_BY_ENTITY_TABLE);
7477                                    }
7478    
7479                                    query.append(orderByConditionFields[i]);
7480    
7481                                    if ((i + 1) < orderByConditionFields.length) {
7482                                            if (orderByComparator.isAscending() ^ previous) {
7483                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7484                                            }
7485                                            else {
7486                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7487                                            }
7488                                    }
7489                                    else {
7490                                            if (orderByComparator.isAscending() ^ previous) {
7491                                                    query.append(WHERE_GREATER_THAN);
7492                                            }
7493                                            else {
7494                                                    query.append(WHERE_LESSER_THAN);
7495                                            }
7496                                    }
7497                            }
7498    
7499                            query.append(ORDER_BY_CLAUSE);
7500    
7501                            String[] orderByFields = orderByComparator.getOrderByFields();
7502    
7503                            for (int i = 0; i < orderByFields.length; i++) {
7504                                    if (getDB().isSupportsInlineDistinct()) {
7505                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7506                                    }
7507                                    else {
7508                                            query.append(_ORDER_BY_ENTITY_TABLE);
7509                                    }
7510    
7511                                    query.append(orderByFields[i]);
7512    
7513                                    if ((i + 1) < orderByFields.length) {
7514                                            if (orderByComparator.isAscending() ^ previous) {
7515                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7516                                            }
7517                                            else {
7518                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7519                                            }
7520                                    }
7521                                    else {
7522                                            if (orderByComparator.isAscending() ^ previous) {
7523                                                    query.append(ORDER_BY_ASC);
7524                                            }
7525                                            else {
7526                                                    query.append(ORDER_BY_DESC);
7527                                            }
7528                                    }
7529                            }
7530                    }
7531                    else {
7532                            if (getDB().isSupportsInlineDistinct()) {
7533                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7534                            }
7535                            else {
7536                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7537                            }
7538                    }
7539    
7540                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7541                                    JournalArticle.class.getName(),
7542                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7543    
7544                    SQLQuery q = session.createSQLQuery(sql);
7545    
7546                    q.setFirstResult(0);
7547                    q.setMaxResults(2);
7548    
7549                    if (getDB().isSupportsInlineDistinct()) {
7550                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7551                    }
7552                    else {
7553                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7554                    }
7555    
7556                    QueryPos qPos = QueryPos.getInstance(q);
7557    
7558                    qPos.add(groupId);
7559    
7560                    qPos.add(userId);
7561    
7562                    if (orderByComparator != null) {
7563                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7564    
7565                            for (Object value : values) {
7566                                    qPos.add(value);
7567                            }
7568                    }
7569    
7570                    List<JournalArticle> list = q.list();
7571    
7572                    if (list.size() == 2) {
7573                            return list.get(1);
7574                    }
7575                    else {
7576                            return null;
7577                    }
7578            }
7579    
7580            /**
7581             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
7582             *
7583             * @param groupId the group ID
7584             * @param userId the user ID
7585             * @throws SystemException if a system exception occurred
7586             */
7587            @Override
7588            public void removeByG_U(long groupId, long userId)
7589                    throws SystemException {
7590                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
7591                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7592                            remove(journalArticle);
7593                    }
7594            }
7595    
7596            /**
7597             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
7598             *
7599             * @param groupId the group ID
7600             * @param userId the user ID
7601             * @return the number of matching journal articles
7602             * @throws SystemException if a system exception occurred
7603             */
7604            @Override
7605            public int countByG_U(long groupId, long userId) throws SystemException {
7606                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
7607    
7608                    Object[] finderArgs = new Object[] { groupId, userId };
7609    
7610                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7611                                    this);
7612    
7613                    if (count == null) {
7614                            StringBundler query = new StringBundler(3);
7615    
7616                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7617    
7618                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7619    
7620                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7621    
7622                            String sql = query.toString();
7623    
7624                            Session session = null;
7625    
7626                            try {
7627                                    session = openSession();
7628    
7629                                    Query q = session.createQuery(sql);
7630    
7631                                    QueryPos qPos = QueryPos.getInstance(q);
7632    
7633                                    qPos.add(groupId);
7634    
7635                                    qPos.add(userId);
7636    
7637                                    count = (Long)q.uniqueResult();
7638    
7639                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7640                            }
7641                            catch (Exception e) {
7642                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7643    
7644                                    throw processException(e);
7645                            }
7646                            finally {
7647                                    closeSession(session);
7648                            }
7649                    }
7650    
7651                    return count.intValue();
7652            }
7653    
7654            /**
7655             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7656             *
7657             * @param groupId the group ID
7658             * @param userId the user ID
7659             * @return the number of matching journal articles that the user has permission to view
7660             * @throws SystemException if a system exception occurred
7661             */
7662            @Override
7663            public int filterCountByG_U(long groupId, long userId)
7664                    throws SystemException {
7665                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7666                            return countByG_U(groupId, userId);
7667                    }
7668    
7669                    StringBundler query = new StringBundler(3);
7670    
7671                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7672    
7673                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7674    
7675                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7676    
7677                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7678                                    JournalArticle.class.getName(),
7679                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7680    
7681                    Session session = null;
7682    
7683                    try {
7684                            session = openSession();
7685    
7686                            SQLQuery q = session.createSQLQuery(sql);
7687    
7688                            q.addScalar(COUNT_COLUMN_NAME,
7689                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7690    
7691                            QueryPos qPos = QueryPos.getInstance(q);
7692    
7693                            qPos.add(groupId);
7694    
7695                            qPos.add(userId);
7696    
7697                            Long count = (Long)q.uniqueResult();
7698    
7699                            return count.intValue();
7700                    }
7701                    catch (Exception e) {
7702                            throw processException(e);
7703                    }
7704                    finally {
7705                            closeSession(session);
7706                    }
7707            }
7708    
7709            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
7710            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
7711            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7712                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7713                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7714                            "findByG_F",
7715                            new String[] {
7716                                    Long.class.getName(), Long.class.getName(),
7717                                    
7718                            Integer.class.getName(), Integer.class.getName(),
7719                                    OrderByComparator.class.getName()
7720                            });
7721            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7722                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7723                            JournalArticleImpl.class,
7724                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
7725                            new String[] { Long.class.getName(), Long.class.getName() },
7726                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7727                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
7728                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7729                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7730            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7731                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7732                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
7733                            new String[] { Long.class.getName(), Long.class.getName() });
7734            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7735                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7736                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
7737                            new String[] { Long.class.getName(), Long.class.getName() });
7738    
7739            /**
7740             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
7741             *
7742             * @param groupId the group ID
7743             * @param folderId the folder ID
7744             * @return the matching journal articles
7745             * @throws SystemException if a system exception occurred
7746             */
7747            @Override
7748            public List<JournalArticle> findByG_F(long groupId, long folderId)
7749                    throws SystemException {
7750                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
7751                            QueryUtil.ALL_POS, null);
7752            }
7753    
7754            /**
7755             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
7756             *
7757             * <p>
7758             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7759             * </p>
7760             *
7761             * @param groupId the group ID
7762             * @param folderId the folder ID
7763             * @param start the lower bound of the range of journal articles
7764             * @param end the upper bound of the range of journal articles (not inclusive)
7765             * @return the range of matching journal articles
7766             * @throws SystemException if a system exception occurred
7767             */
7768            @Override
7769            public List<JournalArticle> findByG_F(long groupId, long folderId,
7770                    int start, int end) throws SystemException {
7771                    return findByG_F(groupId, folderId, start, end, null);
7772            }
7773    
7774            /**
7775             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
7776             *
7777             * <p>
7778             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7779             * </p>
7780             *
7781             * @param groupId the group ID
7782             * @param folderId the folder ID
7783             * @param start the lower bound of the range of journal articles
7784             * @param end the upper bound of the range of journal articles (not inclusive)
7785             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7786             * @return the ordered range of matching journal articles
7787             * @throws SystemException if a system exception occurred
7788             */
7789            @Override
7790            public List<JournalArticle> findByG_F(long groupId, long folderId,
7791                    int start, int end, OrderByComparator orderByComparator)
7792                    throws SystemException {
7793                    boolean pagination = true;
7794                    FinderPath finderPath = null;
7795                    Object[] finderArgs = null;
7796    
7797                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7798                                    (orderByComparator == null)) {
7799                            pagination = false;
7800                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
7801                            finderArgs = new Object[] { groupId, folderId };
7802                    }
7803                    else {
7804                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
7805                            finderArgs = new Object[] {
7806                                            groupId, folderId,
7807                                            
7808                                            start, end, orderByComparator
7809                                    };
7810                    }
7811    
7812                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7813                                    finderArgs, this);
7814    
7815                    if ((list != null) && !list.isEmpty()) {
7816                            for (JournalArticle journalArticle : list) {
7817                                    if ((groupId != journalArticle.getGroupId()) ||
7818                                                    (folderId != journalArticle.getFolderId())) {
7819                                            list = null;
7820    
7821                                            break;
7822                                    }
7823                            }
7824                    }
7825    
7826                    if (list == null) {
7827                            StringBundler query = null;
7828    
7829                            if (orderByComparator != null) {
7830                                    query = new StringBundler(4 +
7831                                                    (orderByComparator.getOrderByFields().length * 3));
7832                            }
7833                            else {
7834                                    query = new StringBundler(4);
7835                            }
7836    
7837                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7838    
7839                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7840    
7841                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7842    
7843                            if (orderByComparator != null) {
7844                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7845                                            orderByComparator);
7846                            }
7847                            else
7848                             if (pagination) {
7849                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7850                            }
7851    
7852                            String sql = query.toString();
7853    
7854                            Session session = null;
7855    
7856                            try {
7857                                    session = openSession();
7858    
7859                                    Query q = session.createQuery(sql);
7860    
7861                                    QueryPos qPos = QueryPos.getInstance(q);
7862    
7863                                    qPos.add(groupId);
7864    
7865                                    qPos.add(folderId);
7866    
7867                                    if (!pagination) {
7868                                            list = (List<JournalArticle>)QueryUtil.list(q,
7869                                                            getDialect(), start, end, false);
7870    
7871                                            Collections.sort(list);
7872    
7873                                            list = new UnmodifiableList<JournalArticle>(list);
7874                                    }
7875                                    else {
7876                                            list = (List<JournalArticle>)QueryUtil.list(q,
7877                                                            getDialect(), start, end);
7878                                    }
7879    
7880                                    cacheResult(list);
7881    
7882                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7883                            }
7884                            catch (Exception e) {
7885                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7886    
7887                                    throw processException(e);
7888                            }
7889                            finally {
7890                                    closeSession(session);
7891                            }
7892                    }
7893    
7894                    return list;
7895            }
7896    
7897            /**
7898             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7899             *
7900             * @param groupId the group ID
7901             * @param folderId the folder ID
7902             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7903             * @return the first matching journal article
7904             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7905             * @throws SystemException if a system exception occurred
7906             */
7907            @Override
7908            public JournalArticle findByG_F_First(long groupId, long folderId,
7909                    OrderByComparator orderByComparator)
7910                    throws NoSuchArticleException, SystemException {
7911                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
7912                                    orderByComparator);
7913    
7914                    if (journalArticle != null) {
7915                            return journalArticle;
7916                    }
7917    
7918                    StringBundler msg = new StringBundler(6);
7919    
7920                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7921    
7922                    msg.append("groupId=");
7923                    msg.append(groupId);
7924    
7925                    msg.append(", folderId=");
7926                    msg.append(folderId);
7927    
7928                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7929    
7930                    throw new NoSuchArticleException(msg.toString());
7931            }
7932    
7933            /**
7934             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7935             *
7936             * @param groupId the group ID
7937             * @param folderId the folder ID
7938             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7939             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7940             * @throws SystemException if a system exception occurred
7941             */
7942            @Override
7943            public JournalArticle fetchByG_F_First(long groupId, long folderId,
7944                    OrderByComparator orderByComparator) throws SystemException {
7945                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
7946                                    orderByComparator);
7947    
7948                    if (!list.isEmpty()) {
7949                            return list.get(0);
7950                    }
7951    
7952                    return null;
7953            }
7954    
7955            /**
7956             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7957             *
7958             * @param groupId the group ID
7959             * @param folderId the folder ID
7960             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7961             * @return the last matching journal article
7962             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7963             * @throws SystemException if a system exception occurred
7964             */
7965            @Override
7966            public JournalArticle findByG_F_Last(long groupId, long folderId,
7967                    OrderByComparator orderByComparator)
7968                    throws NoSuchArticleException, SystemException {
7969                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
7970                                    orderByComparator);
7971    
7972                    if (journalArticle != null) {
7973                            return journalArticle;
7974                    }
7975    
7976                    StringBundler msg = new StringBundler(6);
7977    
7978                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7979    
7980                    msg.append("groupId=");
7981                    msg.append(groupId);
7982    
7983                    msg.append(", folderId=");
7984                    msg.append(folderId);
7985    
7986                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7987    
7988                    throw new NoSuchArticleException(msg.toString());
7989            }
7990    
7991            /**
7992             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7993             *
7994             * @param groupId the group ID
7995             * @param folderId the folder ID
7996             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7997             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7998             * @throws SystemException if a system exception occurred
7999             */
8000            @Override
8001            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
8002                    OrderByComparator orderByComparator) throws SystemException {
8003                    int count = countByG_F(groupId, folderId);
8004    
8005                    if (count == 0) {
8006                            return null;
8007                    }
8008    
8009                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
8010                                    count, orderByComparator);
8011    
8012                    if (!list.isEmpty()) {
8013                            return list.get(0);
8014                    }
8015    
8016                    return null;
8017            }
8018    
8019            /**
8020             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8021             *
8022             * @param id the primary key of the current journal article
8023             * @param groupId the group ID
8024             * @param folderId the folder ID
8025             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8026             * @return the previous, current, and next journal article
8027             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8028             * @throws SystemException if a system exception occurred
8029             */
8030            @Override
8031            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
8032                    long folderId, OrderByComparator orderByComparator)
8033                    throws NoSuchArticleException, SystemException {
8034                    JournalArticle journalArticle = findByPrimaryKey(id);
8035    
8036                    Session session = null;
8037    
8038                    try {
8039                            session = openSession();
8040    
8041                            JournalArticle[] array = new JournalArticleImpl[3];
8042    
8043                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8044                                            folderId, orderByComparator, true);
8045    
8046                            array[1] = journalArticle;
8047    
8048                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8049                                            folderId, orderByComparator, false);
8050    
8051                            return array;
8052                    }
8053                    catch (Exception e) {
8054                            throw processException(e);
8055                    }
8056                    finally {
8057                            closeSession(session);
8058                    }
8059            }
8060    
8061            protected JournalArticle getByG_F_PrevAndNext(Session session,
8062                    JournalArticle journalArticle, long groupId, long folderId,
8063                    OrderByComparator orderByComparator, boolean previous) {
8064                    StringBundler query = null;
8065    
8066                    if (orderByComparator != null) {
8067                            query = new StringBundler(6 +
8068                                            (orderByComparator.getOrderByFields().length * 6));
8069                    }
8070                    else {
8071                            query = new StringBundler(3);
8072                    }
8073    
8074                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8075    
8076                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8077    
8078                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8079    
8080                    if (orderByComparator != null) {
8081                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8082    
8083                            if (orderByConditionFields.length > 0) {
8084                                    query.append(WHERE_AND);
8085                            }
8086    
8087                            for (int i = 0; i < orderByConditionFields.length; i++) {
8088                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8089                                    query.append(orderByConditionFields[i]);
8090    
8091                                    if ((i + 1) < orderByConditionFields.length) {
8092                                            if (orderByComparator.isAscending() ^ previous) {
8093                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8094                                            }
8095                                            else {
8096                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8097                                            }
8098                                    }
8099                                    else {
8100                                            if (orderByComparator.isAscending() ^ previous) {
8101                                                    query.append(WHERE_GREATER_THAN);
8102                                            }
8103                                            else {
8104                                                    query.append(WHERE_LESSER_THAN);
8105                                            }
8106                                    }
8107                            }
8108    
8109                            query.append(ORDER_BY_CLAUSE);
8110    
8111                            String[] orderByFields = orderByComparator.getOrderByFields();
8112    
8113                            for (int i = 0; i < orderByFields.length; i++) {
8114                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8115                                    query.append(orderByFields[i]);
8116    
8117                                    if ((i + 1) < orderByFields.length) {
8118                                            if (orderByComparator.isAscending() ^ previous) {
8119                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8120                                            }
8121                                            else {
8122                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8123                                            }
8124                                    }
8125                                    else {
8126                                            if (orderByComparator.isAscending() ^ previous) {
8127                                                    query.append(ORDER_BY_ASC);
8128                                            }
8129                                            else {
8130                                                    query.append(ORDER_BY_DESC);
8131                                            }
8132                                    }
8133                            }
8134                    }
8135                    else {
8136                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8137                    }
8138    
8139                    String sql = query.toString();
8140    
8141                    Query q = session.createQuery(sql);
8142    
8143                    q.setFirstResult(0);
8144                    q.setMaxResults(2);
8145    
8146                    QueryPos qPos = QueryPos.getInstance(q);
8147    
8148                    qPos.add(groupId);
8149    
8150                    qPos.add(folderId);
8151    
8152                    if (orderByComparator != null) {
8153                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8154    
8155                            for (Object value : values) {
8156                                    qPos.add(value);
8157                            }
8158                    }
8159    
8160                    List<JournalArticle> list = q.list();
8161    
8162                    if (list.size() == 2) {
8163                            return list.get(1);
8164                    }
8165                    else {
8166                            return null;
8167                    }
8168            }
8169    
8170            /**
8171             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8172             *
8173             * @param groupId the group ID
8174             * @param folderId the folder ID
8175             * @return the matching journal articles that the user has permission to view
8176             * @throws SystemException if a system exception occurred
8177             */
8178            @Override
8179            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
8180                    throws SystemException {
8181                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
8182                            QueryUtil.ALL_POS, null);
8183            }
8184    
8185            /**
8186             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8187             *
8188             * <p>
8189             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8190             * </p>
8191             *
8192             * @param groupId the group ID
8193             * @param folderId the folder ID
8194             * @param start the lower bound of the range of journal articles
8195             * @param end the upper bound of the range of journal articles (not inclusive)
8196             * @return the range of matching journal articles that the user has permission to view
8197             * @throws SystemException if a system exception occurred
8198             */
8199            @Override
8200            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8201                    int start, int end) throws SystemException {
8202                    return filterFindByG_F(groupId, folderId, start, end, null);
8203            }
8204    
8205            /**
8206             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
8207             *
8208             * <p>
8209             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8210             * </p>
8211             *
8212             * @param groupId the group ID
8213             * @param folderId the folder ID
8214             * @param start the lower bound of the range of journal articles
8215             * @param end the upper bound of the range of journal articles (not inclusive)
8216             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8217             * @return the ordered range of matching journal articles that the user has permission to view
8218             * @throws SystemException if a system exception occurred
8219             */
8220            @Override
8221            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8222                    int start, int end, OrderByComparator orderByComparator)
8223                    throws SystemException {
8224                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8225                            return findByG_F(groupId, folderId, start, end, orderByComparator);
8226                    }
8227    
8228                    StringBundler query = null;
8229    
8230                    if (orderByComparator != null) {
8231                            query = new StringBundler(4 +
8232                                            (orderByComparator.getOrderByFields().length * 3));
8233                    }
8234                    else {
8235                            query = new StringBundler(4);
8236                    }
8237    
8238                    if (getDB().isSupportsInlineDistinct()) {
8239                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8240                    }
8241                    else {
8242                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8243                    }
8244    
8245                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8246    
8247                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8248    
8249                    if (!getDB().isSupportsInlineDistinct()) {
8250                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8251                    }
8252    
8253                    if (orderByComparator != null) {
8254                            if (getDB().isSupportsInlineDistinct()) {
8255                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8256                                            orderByComparator, true);
8257                            }
8258                            else {
8259                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8260                                            orderByComparator, true);
8261                            }
8262                    }
8263                    else {
8264                            if (getDB().isSupportsInlineDistinct()) {
8265                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8266                            }
8267                            else {
8268                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8269                            }
8270                    }
8271    
8272                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8273                                    JournalArticle.class.getName(),
8274                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8275    
8276                    Session session = null;
8277    
8278                    try {
8279                            session = openSession();
8280    
8281                            SQLQuery q = session.createSQLQuery(sql);
8282    
8283                            if (getDB().isSupportsInlineDistinct()) {
8284                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8285                            }
8286                            else {
8287                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8288                            }
8289    
8290                            QueryPos qPos = QueryPos.getInstance(q);
8291    
8292                            qPos.add(groupId);
8293    
8294                            qPos.add(folderId);
8295    
8296                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8297                                    end);
8298                    }
8299                    catch (Exception e) {
8300                            throw processException(e);
8301                    }
8302                    finally {
8303                            closeSession(session);
8304                    }
8305            }
8306    
8307            /**
8308             * 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;.
8309             *
8310             * @param id the primary key of the current journal article
8311             * @param groupId the group ID
8312             * @param folderId the folder ID
8313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8314             * @return the previous, current, and next journal article
8315             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8316             * @throws SystemException if a system exception occurred
8317             */
8318            @Override
8319            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
8320                    long folderId, OrderByComparator orderByComparator)
8321                    throws NoSuchArticleException, SystemException {
8322                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8323                            return findByG_F_PrevAndNext(id, groupId, folderId,
8324                                    orderByComparator);
8325                    }
8326    
8327                    JournalArticle journalArticle = findByPrimaryKey(id);
8328    
8329                    Session session = null;
8330    
8331                    try {
8332                            session = openSession();
8333    
8334                            JournalArticle[] array = new JournalArticleImpl[3];
8335    
8336                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
8337                                            groupId, folderId, orderByComparator, true);
8338    
8339                            array[1] = journalArticle;
8340    
8341                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
8342                                            groupId, folderId, orderByComparator, false);
8343    
8344                            return array;
8345                    }
8346                    catch (Exception e) {
8347                            throw processException(e);
8348                    }
8349                    finally {
8350                            closeSession(session);
8351                    }
8352            }
8353    
8354            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
8355                    JournalArticle journalArticle, long groupId, long folderId,
8356                    OrderByComparator orderByComparator, boolean previous) {
8357                    StringBundler query = null;
8358    
8359                    if (orderByComparator != null) {
8360                            query = new StringBundler(6 +
8361                                            (orderByComparator.getOrderByFields().length * 6));
8362                    }
8363                    else {
8364                            query = new StringBundler(3);
8365                    }
8366    
8367                    if (getDB().isSupportsInlineDistinct()) {
8368                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8369                    }
8370                    else {
8371                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8372                    }
8373    
8374                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8375    
8376                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8377    
8378                    if (!getDB().isSupportsInlineDistinct()) {
8379                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8380                    }
8381    
8382                    if (orderByComparator != null) {
8383                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8384    
8385                            if (orderByConditionFields.length > 0) {
8386                                    query.append(WHERE_AND);
8387                            }
8388    
8389                            for (int i = 0; i < orderByConditionFields.length; i++) {
8390                                    if (getDB().isSupportsInlineDistinct()) {
8391                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8392                                    }
8393                                    else {
8394                                            query.append(_ORDER_BY_ENTITY_TABLE);
8395                                    }
8396    
8397                                    query.append(orderByConditionFields[i]);
8398    
8399                                    if ((i + 1) < orderByConditionFields.length) {
8400                                            if (orderByComparator.isAscending() ^ previous) {
8401                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8402                                            }
8403                                            else {
8404                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8405                                            }
8406                                    }
8407                                    else {
8408                                            if (orderByComparator.isAscending() ^ previous) {
8409                                                    query.append(WHERE_GREATER_THAN);
8410                                            }
8411                                            else {
8412                                                    query.append(WHERE_LESSER_THAN);
8413                                            }
8414                                    }
8415                            }
8416    
8417                            query.append(ORDER_BY_CLAUSE);
8418    
8419                            String[] orderByFields = orderByComparator.getOrderByFields();
8420    
8421                            for (int i = 0; i < orderByFields.length; i++) {
8422                                    if (getDB().isSupportsInlineDistinct()) {
8423                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8424                                    }
8425                                    else {
8426                                            query.append(_ORDER_BY_ENTITY_TABLE);
8427                                    }
8428    
8429                                    query.append(orderByFields[i]);
8430    
8431                                    if ((i + 1) < orderByFields.length) {
8432                                            if (orderByComparator.isAscending() ^ previous) {
8433                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8434                                            }
8435                                            else {
8436                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8437                                            }
8438                                    }
8439                                    else {
8440                                            if (orderByComparator.isAscending() ^ previous) {
8441                                                    query.append(ORDER_BY_ASC);
8442                                            }
8443                                            else {
8444                                                    query.append(ORDER_BY_DESC);
8445                                            }
8446                                    }
8447                            }
8448                    }
8449                    else {
8450                            if (getDB().isSupportsInlineDistinct()) {
8451                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8452                            }
8453                            else {
8454                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8455                            }
8456                    }
8457    
8458                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8459                                    JournalArticle.class.getName(),
8460                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8461    
8462                    SQLQuery q = session.createSQLQuery(sql);
8463    
8464                    q.setFirstResult(0);
8465                    q.setMaxResults(2);
8466    
8467                    if (getDB().isSupportsInlineDistinct()) {
8468                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8469                    }
8470                    else {
8471                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8472                    }
8473    
8474                    QueryPos qPos = QueryPos.getInstance(q);
8475    
8476                    qPos.add(groupId);
8477    
8478                    qPos.add(folderId);
8479    
8480                    if (orderByComparator != null) {
8481                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8482    
8483                            for (Object value : values) {
8484                                    qPos.add(value);
8485                            }
8486                    }
8487    
8488                    List<JournalArticle> list = q.list();
8489    
8490                    if (list.size() == 2) {
8491                            return list.get(1);
8492                    }
8493                    else {
8494                            return null;
8495                    }
8496            }
8497    
8498            /**
8499             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8500             *
8501             * @param groupId the group ID
8502             * @param folderIds the folder IDs
8503             * @return the 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[] folderIds)
8508                    throws SystemException {
8509                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8510                            QueryUtil.ALL_POS, null);
8511            }
8512    
8513            /**
8514             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8515             *
8516             * <p>
8517             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8518             * </p>
8519             *
8520             * @param groupId the group ID
8521             * @param folderIds the folder IDs
8522             * @param start the lower bound of the range of journal articles
8523             * @param end the upper bound of the range of journal articles (not inclusive)
8524             * @return the range of matching journal articles that the user has permission to view
8525             * @throws SystemException if a system exception occurred
8526             */
8527            @Override
8528            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8529                    int start, int end) throws SystemException {
8530                    return filterFindByG_F(groupId, folderIds, start, end, null);
8531            }
8532    
8533            /**
8534             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8535             *
8536             * <p>
8537             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8538             * </p>
8539             *
8540             * @param groupId the group ID
8541             * @param folderIds the folder IDs
8542             * @param start the lower bound of the range of journal articles
8543             * @param end the upper bound of the range of journal articles (not inclusive)
8544             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8545             * @return the ordered range of matching journal articles that the user has permission to view
8546             * @throws SystemException if a system exception occurred
8547             */
8548            @Override
8549            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8550                    int start, int end, OrderByComparator orderByComparator)
8551                    throws SystemException {
8552                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8553                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8554                    }
8555    
8556                    StringBundler query = new StringBundler();
8557    
8558                    if (getDB().isSupportsInlineDistinct()) {
8559                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8560                    }
8561                    else {
8562                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8563                    }
8564    
8565                    boolean conjunctionable = false;
8566    
8567                    if (conjunctionable) {
8568                            query.append(WHERE_AND);
8569                    }
8570    
8571                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8572    
8573                    conjunctionable = true;
8574    
8575                    if ((folderIds == null) || (folderIds.length > 0)) {
8576                            if (conjunctionable) {
8577                                    query.append(WHERE_AND);
8578                            }
8579    
8580                            query.append(StringPool.OPEN_PARENTHESIS);
8581    
8582                            for (int i = 0; i < folderIds.length; i++) {
8583                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8584    
8585                                    if ((i + 1) < folderIds.length) {
8586                                            query.append(WHERE_OR);
8587                                    }
8588                            }
8589    
8590                            query.append(StringPool.CLOSE_PARENTHESIS);
8591    
8592                            conjunctionable = true;
8593                    }
8594    
8595                    if (!getDB().isSupportsInlineDistinct()) {
8596                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8597                    }
8598    
8599                    if (orderByComparator != null) {
8600                            if (getDB().isSupportsInlineDistinct()) {
8601                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8602                                            orderByComparator, true);
8603                            }
8604                            else {
8605                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8606                                            orderByComparator, true);
8607                            }
8608                    }
8609                    else {
8610                            if (getDB().isSupportsInlineDistinct()) {
8611                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8612                            }
8613                            else {
8614                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8615                            }
8616                    }
8617    
8618                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8619                                    JournalArticle.class.getName(),
8620                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8621    
8622                    Session session = null;
8623    
8624                    try {
8625                            session = openSession();
8626    
8627                            SQLQuery q = session.createSQLQuery(sql);
8628    
8629                            if (getDB().isSupportsInlineDistinct()) {
8630                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8631                            }
8632                            else {
8633                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8634                            }
8635    
8636                            QueryPos qPos = QueryPos.getInstance(q);
8637    
8638                            qPos.add(groupId);
8639    
8640                            if (folderIds != null) {
8641                                    qPos.add(folderIds);
8642                            }
8643    
8644                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8645                                    end);
8646                    }
8647                    catch (Exception e) {
8648                            throw processException(e);
8649                    }
8650                    finally {
8651                            closeSession(session);
8652                    }
8653            }
8654    
8655            /**
8656             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
8657             *
8658             * <p>
8659             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8660             * </p>
8661             *
8662             * @param groupId the group ID
8663             * @param folderIds the folder IDs
8664             * @return the matching journal articles
8665             * @throws SystemException if a system exception occurred
8666             */
8667            @Override
8668            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
8669                    throws SystemException {
8670                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8671                            QueryUtil.ALL_POS, null);
8672            }
8673    
8674            /**
8675             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8676             *
8677             * <p>
8678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8679             * </p>
8680             *
8681             * @param groupId the group ID
8682             * @param folderIds the folder IDs
8683             * @param start the lower bound of the range of journal articles
8684             * @param end the upper bound of the range of journal articles (not inclusive)
8685             * @return the range of matching journal articles
8686             * @throws SystemException if a system exception occurred
8687             */
8688            @Override
8689            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8690                    int start, int end) throws SystemException {
8691                    return findByG_F(groupId, folderIds, start, end, null);
8692            }
8693    
8694            /**
8695             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8696             *
8697             * <p>
8698             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8699             * </p>
8700             *
8701             * @param groupId the group ID
8702             * @param folderIds the folder IDs
8703             * @param start the lower bound of the range of journal articles
8704             * @param end the upper bound of the range of journal articles (not inclusive)
8705             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8706             * @return the ordered range of matching journal articles
8707             * @throws SystemException if a system exception occurred
8708             */
8709            @Override
8710            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8711                    int start, int end, OrderByComparator orderByComparator)
8712                    throws SystemException {
8713                    if ((folderIds != null) && (folderIds.length == 1)) {
8714                            return findByG_F(groupId, folderIds[0], start, end,
8715                                    orderByComparator);
8716                    }
8717    
8718                    boolean pagination = true;
8719                    Object[] finderArgs = null;
8720    
8721                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8722                                    (orderByComparator == null)) {
8723                            pagination = false;
8724                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8725                    }
8726                    else {
8727                            finderArgs = new Object[] {
8728                                            groupId, StringUtil.merge(folderIds),
8729                                            
8730                                            start, end, orderByComparator
8731                                    };
8732                    }
8733    
8734                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8735                                    finderArgs, this);
8736    
8737                    if ((list != null) && !list.isEmpty()) {
8738                            for (JournalArticle journalArticle : list) {
8739                                    if ((groupId != journalArticle.getGroupId()) ||
8740                                                    !ArrayUtil.contains(folderIds,
8741                                                            journalArticle.getFolderId())) {
8742                                            list = null;
8743    
8744                                            break;
8745                                    }
8746                            }
8747                    }
8748    
8749                    if (list == null) {
8750                            StringBundler query = new StringBundler();
8751    
8752                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8753    
8754                            boolean conjunctionable = false;
8755    
8756                            if (conjunctionable) {
8757                                    query.append(WHERE_AND);
8758                            }
8759    
8760                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8761    
8762                            conjunctionable = true;
8763    
8764                            if ((folderIds == null) || (folderIds.length > 0)) {
8765                                    if (conjunctionable) {
8766                                            query.append(WHERE_AND);
8767                                    }
8768    
8769                                    query.append(StringPool.OPEN_PARENTHESIS);
8770    
8771                                    for (int i = 0; i < folderIds.length; i++) {
8772                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8773    
8774                                            if ((i + 1) < folderIds.length) {
8775                                                    query.append(WHERE_OR);
8776                                            }
8777                                    }
8778    
8779                                    query.append(StringPool.CLOSE_PARENTHESIS);
8780    
8781                                    conjunctionable = true;
8782                            }
8783    
8784                            if (orderByComparator != null) {
8785                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8786                                            orderByComparator);
8787                            }
8788                            else
8789                             if (pagination) {
8790                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8791                            }
8792    
8793                            String sql = query.toString();
8794    
8795                            Session session = null;
8796    
8797                            try {
8798                                    session = openSession();
8799    
8800                                    Query q = session.createQuery(sql);
8801    
8802                                    QueryPos qPos = QueryPos.getInstance(q);
8803    
8804                                    qPos.add(groupId);
8805    
8806                                    if (folderIds != null) {
8807                                            qPos.add(folderIds);
8808                                    }
8809    
8810                                    if (!pagination) {
8811                                            list = (List<JournalArticle>)QueryUtil.list(q,
8812                                                            getDialect(), start, end, false);
8813    
8814                                            Collections.sort(list);
8815    
8816                                            list = new UnmodifiableList<JournalArticle>(list);
8817                                    }
8818                                    else {
8819                                            list = (List<JournalArticle>)QueryUtil.list(q,
8820                                                            getDialect(), start, end);
8821                                    }
8822    
8823                                    cacheResult(list);
8824    
8825                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8826                                            finderArgs, list);
8827                            }
8828                            catch (Exception e) {
8829                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8830                                            finderArgs);
8831    
8832                                    throw processException(e);
8833                            }
8834                            finally {
8835                                    closeSession(session);
8836                            }
8837                    }
8838    
8839                    return list;
8840            }
8841    
8842            /**
8843             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
8844             *
8845             * @param groupId the group ID
8846             * @param folderId the folder ID
8847             * @throws SystemException if a system exception occurred
8848             */
8849            @Override
8850            public void removeByG_F(long groupId, long folderId)
8851                    throws SystemException {
8852                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
8853                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8854                            remove(journalArticle);
8855                    }
8856            }
8857    
8858            /**
8859             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
8860             *
8861             * @param groupId the group ID
8862             * @param folderId the folder ID
8863             * @return the number of matching journal articles
8864             * @throws SystemException if a system exception occurred
8865             */
8866            @Override
8867            public int countByG_F(long groupId, long folderId)
8868                    throws SystemException {
8869                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
8870    
8871                    Object[] finderArgs = new Object[] { groupId, folderId };
8872    
8873                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8874                                    this);
8875    
8876                    if (count == null) {
8877                            StringBundler query = new StringBundler(3);
8878    
8879                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8880    
8881                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8882    
8883                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8884    
8885                            String sql = query.toString();
8886    
8887                            Session session = null;
8888    
8889                            try {
8890                                    session = openSession();
8891    
8892                                    Query q = session.createQuery(sql);
8893    
8894                                    QueryPos qPos = QueryPos.getInstance(q);
8895    
8896                                    qPos.add(groupId);
8897    
8898                                    qPos.add(folderId);
8899    
8900                                    count = (Long)q.uniqueResult();
8901    
8902                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8903                            }
8904                            catch (Exception e) {
8905                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8906    
8907                                    throw processException(e);
8908                            }
8909                            finally {
8910                                    closeSession(session);
8911                            }
8912                    }
8913    
8914                    return count.intValue();
8915            }
8916    
8917            /**
8918             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
8919             *
8920             * @param groupId the group ID
8921             * @param folderIds the folder IDs
8922             * @return the number of matching journal articles
8923             * @throws SystemException if a system exception occurred
8924             */
8925            @Override
8926            public int countByG_F(long groupId, long[] folderIds)
8927                    throws SystemException {
8928                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8929    
8930                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8931                                    finderArgs, this);
8932    
8933                    if (count == null) {
8934                            StringBundler query = new StringBundler();
8935    
8936                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8937    
8938                            boolean conjunctionable = false;
8939    
8940                            if (conjunctionable) {
8941                                    query.append(WHERE_AND);
8942                            }
8943    
8944                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8945    
8946                            conjunctionable = true;
8947    
8948                            if ((folderIds == null) || (folderIds.length > 0)) {
8949                                    if (conjunctionable) {
8950                                            query.append(WHERE_AND);
8951                                    }
8952    
8953                                    query.append(StringPool.OPEN_PARENTHESIS);
8954    
8955                                    for (int i = 0; i < folderIds.length; i++) {
8956                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8957    
8958                                            if ((i + 1) < folderIds.length) {
8959                                                    query.append(WHERE_OR);
8960                                            }
8961                                    }
8962    
8963                                    query.append(StringPool.CLOSE_PARENTHESIS);
8964    
8965                                    conjunctionable = true;
8966                            }
8967    
8968                            String sql = query.toString();
8969    
8970                            Session session = null;
8971    
8972                            try {
8973                                    session = openSession();
8974    
8975                                    Query q = session.createQuery(sql);
8976    
8977                                    QueryPos qPos = QueryPos.getInstance(q);
8978    
8979                                    qPos.add(groupId);
8980    
8981                                    if (folderIds != null) {
8982                                            qPos.add(folderIds);
8983                                    }
8984    
8985                                    count = (Long)q.uniqueResult();
8986    
8987                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8988                                            finderArgs, count);
8989                            }
8990                            catch (Exception e) {
8991                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8992                                            finderArgs);
8993    
8994                                    throw processException(e);
8995                            }
8996                            finally {
8997                                    closeSession(session);
8998                            }
8999                    }
9000    
9001                    return count.intValue();
9002            }
9003    
9004            /**
9005             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
9006             *
9007             * @param groupId the group ID
9008             * @param folderId the folder ID
9009             * @return the number of matching journal articles that the user has permission to view
9010             * @throws SystemException if a system exception occurred
9011             */
9012            @Override
9013            public int filterCountByG_F(long groupId, long folderId)
9014                    throws SystemException {
9015                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9016                            return countByG_F(groupId, folderId);
9017                    }
9018    
9019                    StringBundler query = new StringBundler(3);
9020    
9021                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9022    
9023                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9024    
9025                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9026    
9027                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9028                                    JournalArticle.class.getName(),
9029                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9030    
9031                    Session session = null;
9032    
9033                    try {
9034                            session = openSession();
9035    
9036                            SQLQuery q = session.createSQLQuery(sql);
9037    
9038                            q.addScalar(COUNT_COLUMN_NAME,
9039                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9040    
9041                            QueryPos qPos = QueryPos.getInstance(q);
9042    
9043                            qPos.add(groupId);
9044    
9045                            qPos.add(folderId);
9046    
9047                            Long count = (Long)q.uniqueResult();
9048    
9049                            return count.intValue();
9050                    }
9051                    catch (Exception e) {
9052                            throw processException(e);
9053                    }
9054                    finally {
9055                            closeSession(session);
9056                    }
9057            }
9058    
9059            /**
9060             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
9061             *
9062             * @param groupId the group ID
9063             * @param folderIds the folder IDs
9064             * @return the number of matching journal articles that the user has permission to view
9065             * @throws SystemException if a system exception occurred
9066             */
9067            @Override
9068            public int filterCountByG_F(long groupId, long[] folderIds)
9069                    throws SystemException {
9070                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9071                            return countByG_F(groupId, folderIds);
9072                    }
9073    
9074                    StringBundler query = new StringBundler();
9075    
9076                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9077    
9078                    boolean conjunctionable = false;
9079    
9080                    if (conjunctionable) {
9081                            query.append(WHERE_AND);
9082                    }
9083    
9084                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9085    
9086                    conjunctionable = true;
9087    
9088                    if ((folderIds == null) || (folderIds.length > 0)) {
9089                            if (conjunctionable) {
9090                                    query.append(WHERE_AND);
9091                            }
9092    
9093                            query.append(StringPool.OPEN_PARENTHESIS);
9094    
9095                            for (int i = 0; i < folderIds.length; i++) {
9096                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9097    
9098                                    if ((i + 1) < folderIds.length) {
9099                                            query.append(WHERE_OR);
9100                                    }
9101                            }
9102    
9103                            query.append(StringPool.CLOSE_PARENTHESIS);
9104    
9105                            conjunctionable = true;
9106                    }
9107    
9108                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9109                                    JournalArticle.class.getName(),
9110                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9111    
9112                    Session session = null;
9113    
9114                    try {
9115                            session = openSession();
9116    
9117                            SQLQuery q = session.createSQLQuery(sql);
9118    
9119                            q.addScalar(COUNT_COLUMN_NAME,
9120                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9121    
9122                            QueryPos qPos = QueryPos.getInstance(q);
9123    
9124                            qPos.add(groupId);
9125    
9126                            if (folderIds != null) {
9127                                    qPos.add(folderIds);
9128                            }
9129    
9130                            Long count = (Long)q.uniqueResult();
9131    
9132                            return count.intValue();
9133                    }
9134                    catch (Exception e) {
9135                            throw processException(e);
9136                    }
9137                    finally {
9138                            closeSession(session);
9139                    }
9140            }
9141    
9142            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
9143            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
9144                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
9145            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
9146            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
9147                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
9148            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9149                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9150                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9151                            "findByG_A",
9152                            new String[] {
9153                                    Long.class.getName(), String.class.getName(),
9154                                    
9155                            Integer.class.getName(), Integer.class.getName(),
9156                                    OrderByComparator.class.getName()
9157                            });
9158            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9159                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9160                            JournalArticleImpl.class,
9161                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
9162                            new String[] { Long.class.getName(), String.class.getName() },
9163                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9164                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9165                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9166            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9167                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9168                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
9169                            new String[] { Long.class.getName(), String.class.getName() });
9170    
9171            /**
9172             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
9173             *
9174             * @param groupId the group ID
9175             * @param articleId the article ID
9176             * @return the matching journal articles
9177             * @throws SystemException if a system exception occurred
9178             */
9179            @Override
9180            public List<JournalArticle> findByG_A(long groupId, String articleId)
9181                    throws SystemException {
9182                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
9183                            QueryUtil.ALL_POS, null);
9184            }
9185    
9186            /**
9187             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
9188             *
9189             * <p>
9190             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9191             * </p>
9192             *
9193             * @param groupId the group ID
9194             * @param articleId the article ID
9195             * @param start the lower bound of the range of journal articles
9196             * @param end the upper bound of the range of journal articles (not inclusive)
9197             * @return the range of matching journal articles
9198             * @throws SystemException if a system exception occurred
9199             */
9200            @Override
9201            public List<JournalArticle> findByG_A(long groupId, String articleId,
9202                    int start, int end) throws SystemException {
9203                    return findByG_A(groupId, articleId, start, end, null);
9204            }
9205    
9206            /**
9207             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
9208             *
9209             * <p>
9210             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9211             * </p>
9212             *
9213             * @param groupId the group ID
9214             * @param articleId the article ID
9215             * @param start the lower bound of the range of journal articles
9216             * @param end the upper bound of the range of journal articles (not inclusive)
9217             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9218             * @return the ordered range of matching journal articles
9219             * @throws SystemException if a system exception occurred
9220             */
9221            @Override
9222            public List<JournalArticle> findByG_A(long groupId, String articleId,
9223                    int start, int end, OrderByComparator orderByComparator)
9224                    throws SystemException {
9225                    boolean pagination = true;
9226                    FinderPath finderPath = null;
9227                    Object[] finderArgs = null;
9228    
9229                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9230                                    (orderByComparator == null)) {
9231                            pagination = false;
9232                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
9233                            finderArgs = new Object[] { groupId, articleId };
9234                    }
9235                    else {
9236                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
9237                            finderArgs = new Object[] {
9238                                            groupId, articleId,
9239                                            
9240                                            start, end, orderByComparator
9241                                    };
9242                    }
9243    
9244                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9245                                    finderArgs, this);
9246    
9247                    if ((list != null) && !list.isEmpty()) {
9248                            for (JournalArticle journalArticle : list) {
9249                                    if ((groupId != journalArticle.getGroupId()) ||
9250                                                    !Validator.equals(articleId,
9251                                                            journalArticle.getArticleId())) {
9252                                            list = null;
9253    
9254                                            break;
9255                                    }
9256                            }
9257                    }
9258    
9259                    if (list == null) {
9260                            StringBundler query = null;
9261    
9262                            if (orderByComparator != null) {
9263                                    query = new StringBundler(4 +
9264                                                    (orderByComparator.getOrderByFields().length * 3));
9265                            }
9266                            else {
9267                                    query = new StringBundler(4);
9268                            }
9269    
9270                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9271    
9272                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9273    
9274                            boolean bindArticleId = false;
9275    
9276                            if (articleId == null) {
9277                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9278                            }
9279                            else if (articleId.equals(StringPool.BLANK)) {
9280                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9281                            }
9282                            else {
9283                                    bindArticleId = true;
9284    
9285                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9286                            }
9287    
9288                            if (orderByComparator != null) {
9289                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9290                                            orderByComparator);
9291                            }
9292                            else
9293                             if (pagination) {
9294                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9295                            }
9296    
9297                            String sql = query.toString();
9298    
9299                            Session session = null;
9300    
9301                            try {
9302                                    session = openSession();
9303    
9304                                    Query q = session.createQuery(sql);
9305    
9306                                    QueryPos qPos = QueryPos.getInstance(q);
9307    
9308                                    qPos.add(groupId);
9309    
9310                                    if (bindArticleId) {
9311                                            qPos.add(articleId);
9312                                    }
9313    
9314                                    if (!pagination) {
9315                                            list = (List<JournalArticle>)QueryUtil.list(q,
9316                                                            getDialect(), start, end, false);
9317    
9318                                            Collections.sort(list);
9319    
9320                                            list = new UnmodifiableList<JournalArticle>(list);
9321                                    }
9322                                    else {
9323                                            list = (List<JournalArticle>)QueryUtil.list(q,
9324                                                            getDialect(), start, end);
9325                                    }
9326    
9327                                    cacheResult(list);
9328    
9329                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9330                            }
9331                            catch (Exception e) {
9332                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9333    
9334                                    throw processException(e);
9335                            }
9336                            finally {
9337                                    closeSession(session);
9338                            }
9339                    }
9340    
9341                    return list;
9342            }
9343    
9344            /**
9345             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9346             *
9347             * @param groupId the group ID
9348             * @param articleId the article ID
9349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9350             * @return the first matching journal article
9351             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9352             * @throws SystemException if a system exception occurred
9353             */
9354            @Override
9355            public JournalArticle findByG_A_First(long groupId, String articleId,
9356                    OrderByComparator orderByComparator)
9357                    throws NoSuchArticleException, SystemException {
9358                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
9359                                    orderByComparator);
9360    
9361                    if (journalArticle != null) {
9362                            return journalArticle;
9363                    }
9364    
9365                    StringBundler msg = new StringBundler(6);
9366    
9367                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9368    
9369                    msg.append("groupId=");
9370                    msg.append(groupId);
9371    
9372                    msg.append(", articleId=");
9373                    msg.append(articleId);
9374    
9375                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9376    
9377                    throw new NoSuchArticleException(msg.toString());
9378            }
9379    
9380            /**
9381             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9382             *
9383             * @param groupId the group ID
9384             * @param articleId the article ID
9385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9386             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9387             * @throws SystemException if a system exception occurred
9388             */
9389            @Override
9390            public JournalArticle fetchByG_A_First(long groupId, String articleId,
9391                    OrderByComparator orderByComparator) throws SystemException {
9392                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
9393                                    orderByComparator);
9394    
9395                    if (!list.isEmpty()) {
9396                            return list.get(0);
9397                    }
9398    
9399                    return null;
9400            }
9401    
9402            /**
9403             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9404             *
9405             * @param groupId the group ID
9406             * @param articleId the article ID
9407             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9408             * @return the last matching journal article
9409             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9410             * @throws SystemException if a system exception occurred
9411             */
9412            @Override
9413            public JournalArticle findByG_A_Last(long groupId, String articleId,
9414                    OrderByComparator orderByComparator)
9415                    throws NoSuchArticleException, SystemException {
9416                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
9417                                    orderByComparator);
9418    
9419                    if (journalArticle != null) {
9420                            return journalArticle;
9421                    }
9422    
9423                    StringBundler msg = new StringBundler(6);
9424    
9425                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9426    
9427                    msg.append("groupId=");
9428                    msg.append(groupId);
9429    
9430                    msg.append(", articleId=");
9431                    msg.append(articleId);
9432    
9433                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9434    
9435                    throw new NoSuchArticleException(msg.toString());
9436            }
9437    
9438            /**
9439             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9440             *
9441             * @param groupId the group ID
9442             * @param articleId the article ID
9443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9444             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9445             * @throws SystemException if a system exception occurred
9446             */
9447            @Override
9448            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
9449                    OrderByComparator orderByComparator) throws SystemException {
9450                    int count = countByG_A(groupId, articleId);
9451    
9452                    if (count == 0) {
9453                            return null;
9454                    }
9455    
9456                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
9457                                    count, orderByComparator);
9458    
9459                    if (!list.isEmpty()) {
9460                            return list.get(0);
9461                    }
9462    
9463                    return null;
9464            }
9465    
9466            /**
9467             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9468             *
9469             * @param id the primary key of the current journal article
9470             * @param groupId the group ID
9471             * @param articleId the article ID
9472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9473             * @return the previous, current, and next journal article
9474             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9475             * @throws SystemException if a system exception occurred
9476             */
9477            @Override
9478            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
9479                    String articleId, OrderByComparator orderByComparator)
9480                    throws NoSuchArticleException, SystemException {
9481                    JournalArticle journalArticle = findByPrimaryKey(id);
9482    
9483                    Session session = null;
9484    
9485                    try {
9486                            session = openSession();
9487    
9488                            JournalArticle[] array = new JournalArticleImpl[3];
9489    
9490                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9491                                            articleId, orderByComparator, true);
9492    
9493                            array[1] = journalArticle;
9494    
9495                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9496                                            articleId, orderByComparator, false);
9497    
9498                            return array;
9499                    }
9500                    catch (Exception e) {
9501                            throw processException(e);
9502                    }
9503                    finally {
9504                            closeSession(session);
9505                    }
9506            }
9507    
9508            protected JournalArticle getByG_A_PrevAndNext(Session session,
9509                    JournalArticle journalArticle, long groupId, String articleId,
9510                    OrderByComparator orderByComparator, boolean previous) {
9511                    StringBundler query = null;
9512    
9513                    if (orderByComparator != null) {
9514                            query = new StringBundler(6 +
9515                                            (orderByComparator.getOrderByFields().length * 6));
9516                    }
9517                    else {
9518                            query = new StringBundler(3);
9519                    }
9520    
9521                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9522    
9523                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9524    
9525                    boolean bindArticleId = false;
9526    
9527                    if (articleId == null) {
9528                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9529                    }
9530                    else if (articleId.equals(StringPool.BLANK)) {
9531                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9532                    }
9533                    else {
9534                            bindArticleId = true;
9535    
9536                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9537                    }
9538    
9539                    if (orderByComparator != null) {
9540                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9541    
9542                            if (orderByConditionFields.length > 0) {
9543                                    query.append(WHERE_AND);
9544                            }
9545    
9546                            for (int i = 0; i < orderByConditionFields.length; i++) {
9547                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9548                                    query.append(orderByConditionFields[i]);
9549    
9550                                    if ((i + 1) < orderByConditionFields.length) {
9551                                            if (orderByComparator.isAscending() ^ previous) {
9552                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9553                                            }
9554                                            else {
9555                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9556                                            }
9557                                    }
9558                                    else {
9559                                            if (orderByComparator.isAscending() ^ previous) {
9560                                                    query.append(WHERE_GREATER_THAN);
9561                                            }
9562                                            else {
9563                                                    query.append(WHERE_LESSER_THAN);
9564                                            }
9565                                    }
9566                            }
9567    
9568                            query.append(ORDER_BY_CLAUSE);
9569    
9570                            String[] orderByFields = orderByComparator.getOrderByFields();
9571    
9572                            for (int i = 0; i < orderByFields.length; i++) {
9573                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9574                                    query.append(orderByFields[i]);
9575    
9576                                    if ((i + 1) < orderByFields.length) {
9577                                            if (orderByComparator.isAscending() ^ previous) {
9578                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9579                                            }
9580                                            else {
9581                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9582                                            }
9583                                    }
9584                                    else {
9585                                            if (orderByComparator.isAscending() ^ previous) {
9586                                                    query.append(ORDER_BY_ASC);
9587                                            }
9588                                            else {
9589                                                    query.append(ORDER_BY_DESC);
9590                                            }
9591                                    }
9592                            }
9593                    }
9594                    else {
9595                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9596                    }
9597    
9598                    String sql = query.toString();
9599    
9600                    Query q = session.createQuery(sql);
9601    
9602                    q.setFirstResult(0);
9603                    q.setMaxResults(2);
9604    
9605                    QueryPos qPos = QueryPos.getInstance(q);
9606    
9607                    qPos.add(groupId);
9608    
9609                    if (bindArticleId) {
9610                            qPos.add(articleId);
9611                    }
9612    
9613                    if (orderByComparator != null) {
9614                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9615    
9616                            for (Object value : values) {
9617                                    qPos.add(value);
9618                            }
9619                    }
9620    
9621                    List<JournalArticle> list = q.list();
9622    
9623                    if (list.size() == 2) {
9624                            return list.get(1);
9625                    }
9626                    else {
9627                            return null;
9628                    }
9629            }
9630    
9631            /**
9632             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9633             *
9634             * @param groupId the group ID
9635             * @param articleId the article ID
9636             * @return the matching journal articles that the user has permission to view
9637             * @throws SystemException if a system exception occurred
9638             */
9639            @Override
9640            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
9641                    throws SystemException {
9642                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
9643                            QueryUtil.ALL_POS, null);
9644            }
9645    
9646            /**
9647             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9648             *
9649             * <p>
9650             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9651             * </p>
9652             *
9653             * @param groupId the group ID
9654             * @param articleId the article ID
9655             * @param start the lower bound of the range of journal articles
9656             * @param end the upper bound of the range of journal articles (not inclusive)
9657             * @return the range of matching journal articles that the user has permission to view
9658             * @throws SystemException if a system exception occurred
9659             */
9660            @Override
9661            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9662                    int start, int end) throws SystemException {
9663                    return filterFindByG_A(groupId, articleId, start, end, null);
9664            }
9665    
9666            /**
9667             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
9668             *
9669             * <p>
9670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9671             * </p>
9672             *
9673             * @param groupId the group ID
9674             * @param articleId the article ID
9675             * @param start the lower bound of the range of journal articles
9676             * @param end the upper bound of the range of journal articles (not inclusive)
9677             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9678             * @return the ordered range of matching journal articles that the user has permission to view
9679             * @throws SystemException if a system exception occurred
9680             */
9681            @Override
9682            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9683                    int start, int end, OrderByComparator orderByComparator)
9684                    throws SystemException {
9685                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9686                            return findByG_A(groupId, articleId, start, end, orderByComparator);
9687                    }
9688    
9689                    StringBundler query = null;
9690    
9691                    if (orderByComparator != null) {
9692                            query = new StringBundler(4 +
9693                                            (orderByComparator.getOrderByFields().length * 3));
9694                    }
9695                    else {
9696                            query = new StringBundler(4);
9697                    }
9698    
9699                    if (getDB().isSupportsInlineDistinct()) {
9700                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9701                    }
9702                    else {
9703                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9704                    }
9705    
9706                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9707    
9708                    boolean bindArticleId = false;
9709    
9710                    if (articleId == null) {
9711                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9712                    }
9713                    else if (articleId.equals(StringPool.BLANK)) {
9714                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9715                    }
9716                    else {
9717                            bindArticleId = true;
9718    
9719                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9720                    }
9721    
9722                    if (!getDB().isSupportsInlineDistinct()) {
9723                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9724                    }
9725    
9726                    if (orderByComparator != null) {
9727                            if (getDB().isSupportsInlineDistinct()) {
9728                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9729                                            orderByComparator, true);
9730                            }
9731                            else {
9732                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9733                                            orderByComparator, true);
9734                            }
9735                    }
9736                    else {
9737                            if (getDB().isSupportsInlineDistinct()) {
9738                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9739                            }
9740                            else {
9741                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9742                            }
9743                    }
9744    
9745                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9746                                    JournalArticle.class.getName(),
9747                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9748    
9749                    Session session = null;
9750    
9751                    try {
9752                            session = openSession();
9753    
9754                            SQLQuery q = session.createSQLQuery(sql);
9755    
9756                            if (getDB().isSupportsInlineDistinct()) {
9757                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9758                            }
9759                            else {
9760                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9761                            }
9762    
9763                            QueryPos qPos = QueryPos.getInstance(q);
9764    
9765                            qPos.add(groupId);
9766    
9767                            if (bindArticleId) {
9768                                    qPos.add(articleId);
9769                            }
9770    
9771                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9772                                    end);
9773                    }
9774                    catch (Exception e) {
9775                            throw processException(e);
9776                    }
9777                    finally {
9778                            closeSession(session);
9779                    }
9780            }
9781    
9782            /**
9783             * 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;.
9784             *
9785             * @param id the primary key of the current journal article
9786             * @param groupId the group ID
9787             * @param articleId the article ID
9788             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9789             * @return the previous, current, and next journal article
9790             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9791             * @throws SystemException if a system exception occurred
9792             */
9793            @Override
9794            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
9795                    String articleId, OrderByComparator orderByComparator)
9796                    throws NoSuchArticleException, SystemException {
9797                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9798                            return findByG_A_PrevAndNext(id, groupId, articleId,
9799                                    orderByComparator);
9800                    }
9801    
9802                    JournalArticle journalArticle = findByPrimaryKey(id);
9803    
9804                    Session session = null;
9805    
9806                    try {
9807                            session = openSession();
9808    
9809                            JournalArticle[] array = new JournalArticleImpl[3];
9810    
9811                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
9812                                            groupId, articleId, orderByComparator, true);
9813    
9814                            array[1] = journalArticle;
9815    
9816                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
9817                                            groupId, articleId, orderByComparator, false);
9818    
9819                            return array;
9820                    }
9821                    catch (Exception e) {
9822                            throw processException(e);
9823                    }
9824                    finally {
9825                            closeSession(session);
9826                    }
9827            }
9828    
9829            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
9830                    JournalArticle journalArticle, long groupId, String articleId,
9831                    OrderByComparator orderByComparator, boolean previous) {
9832                    StringBundler query = null;
9833    
9834                    if (orderByComparator != null) {
9835                            query = new StringBundler(6 +
9836                                            (orderByComparator.getOrderByFields().length * 6));
9837                    }
9838                    else {
9839                            query = new StringBundler(3);
9840                    }
9841    
9842                    if (getDB().isSupportsInlineDistinct()) {
9843                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9844                    }
9845                    else {
9846                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9847                    }
9848    
9849                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9850    
9851                    boolean bindArticleId = false;
9852    
9853                    if (articleId == null) {
9854                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9855                    }
9856                    else if (articleId.equals(StringPool.BLANK)) {
9857                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9858                    }
9859                    else {
9860                            bindArticleId = true;
9861    
9862                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9863                    }
9864    
9865                    if (!getDB().isSupportsInlineDistinct()) {
9866                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9867                    }
9868    
9869                    if (orderByComparator != null) {
9870                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9871    
9872                            if (orderByConditionFields.length > 0) {
9873                                    query.append(WHERE_AND);
9874                            }
9875    
9876                            for (int i = 0; i < orderByConditionFields.length; i++) {
9877                                    if (getDB().isSupportsInlineDistinct()) {
9878                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9879                                    }
9880                                    else {
9881                                            query.append(_ORDER_BY_ENTITY_TABLE);
9882                                    }
9883    
9884                                    query.append(orderByConditionFields[i]);
9885    
9886                                    if ((i + 1) < orderByConditionFields.length) {
9887                                            if (orderByComparator.isAscending() ^ previous) {
9888                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9889                                            }
9890                                            else {
9891                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9892                                            }
9893                                    }
9894                                    else {
9895                                            if (orderByComparator.isAscending() ^ previous) {
9896                                                    query.append(WHERE_GREATER_THAN);
9897                                            }
9898                                            else {
9899                                                    query.append(WHERE_LESSER_THAN);
9900                                            }
9901                                    }
9902                            }
9903    
9904                            query.append(ORDER_BY_CLAUSE);
9905    
9906                            String[] orderByFields = orderByComparator.getOrderByFields();
9907    
9908                            for (int i = 0; i < orderByFields.length; i++) {
9909                                    if (getDB().isSupportsInlineDistinct()) {
9910                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9911                                    }
9912                                    else {
9913                                            query.append(_ORDER_BY_ENTITY_TABLE);
9914                                    }
9915    
9916                                    query.append(orderByFields[i]);
9917    
9918                                    if ((i + 1) < orderByFields.length) {
9919                                            if (orderByComparator.isAscending() ^ previous) {
9920                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9921                                            }
9922                                            else {
9923                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9924                                            }
9925                                    }
9926                                    else {
9927                                            if (orderByComparator.isAscending() ^ previous) {
9928                                                    query.append(ORDER_BY_ASC);
9929                                            }
9930                                            else {
9931                                                    query.append(ORDER_BY_DESC);
9932                                            }
9933                                    }
9934                            }
9935                    }
9936                    else {
9937                            if (getDB().isSupportsInlineDistinct()) {
9938                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9939                            }
9940                            else {
9941                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9942                            }
9943                    }
9944    
9945                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9946                                    JournalArticle.class.getName(),
9947                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9948    
9949                    SQLQuery q = session.createSQLQuery(sql);
9950    
9951                    q.setFirstResult(0);
9952                    q.setMaxResults(2);
9953    
9954                    if (getDB().isSupportsInlineDistinct()) {
9955                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9956                    }
9957                    else {
9958                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9959                    }
9960    
9961                    QueryPos qPos = QueryPos.getInstance(q);
9962    
9963                    qPos.add(groupId);
9964    
9965                    if (bindArticleId) {
9966                            qPos.add(articleId);
9967                    }
9968    
9969                    if (orderByComparator != null) {
9970                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9971    
9972                            for (Object value : values) {
9973                                    qPos.add(value);
9974                            }
9975                    }
9976    
9977                    List<JournalArticle> list = q.list();
9978    
9979                    if (list.size() == 2) {
9980                            return list.get(1);
9981                    }
9982                    else {
9983                            return null;
9984                    }
9985            }
9986    
9987            /**
9988             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
9989             *
9990             * @param groupId the group ID
9991             * @param articleId the article ID
9992             * @throws SystemException if a system exception occurred
9993             */
9994            @Override
9995            public void removeByG_A(long groupId, String articleId)
9996                    throws SystemException {
9997                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
9998                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9999                            remove(journalArticle);
10000                    }
10001            }
10002    
10003            /**
10004             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
10005             *
10006             * @param groupId the group ID
10007             * @param articleId the article ID
10008             * @return the number of matching journal articles
10009             * @throws SystemException if a system exception occurred
10010             */
10011            @Override
10012            public int countByG_A(long groupId, String articleId)
10013                    throws SystemException {
10014                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
10015    
10016                    Object[] finderArgs = new Object[] { groupId, articleId };
10017    
10018                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10019                                    this);
10020    
10021                    if (count == null) {
10022                            StringBundler query = new StringBundler(3);
10023    
10024                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10025    
10026                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10027    
10028                            boolean bindArticleId = false;
10029    
10030                            if (articleId == null) {
10031                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10032                            }
10033                            else if (articleId.equals(StringPool.BLANK)) {
10034                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10035                            }
10036                            else {
10037                                    bindArticleId = true;
10038    
10039                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10040                            }
10041    
10042                            String sql = query.toString();
10043    
10044                            Session session = null;
10045    
10046                            try {
10047                                    session = openSession();
10048    
10049                                    Query q = session.createQuery(sql);
10050    
10051                                    QueryPos qPos = QueryPos.getInstance(q);
10052    
10053                                    qPos.add(groupId);
10054    
10055                                    if (bindArticleId) {
10056                                            qPos.add(articleId);
10057                                    }
10058    
10059                                    count = (Long)q.uniqueResult();
10060    
10061                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10062                            }
10063                            catch (Exception e) {
10064                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10065    
10066                                    throw processException(e);
10067                            }
10068                            finally {
10069                                    closeSession(session);
10070                            }
10071                    }
10072    
10073                    return count.intValue();
10074            }
10075    
10076            /**
10077             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
10078             *
10079             * @param groupId the group ID
10080             * @param articleId the article ID
10081             * @return the number of matching journal articles that the user has permission to view
10082             * @throws SystemException if a system exception occurred
10083             */
10084            @Override
10085            public int filterCountByG_A(long groupId, String articleId)
10086                    throws SystemException {
10087                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10088                            return countByG_A(groupId, articleId);
10089                    }
10090    
10091                    StringBundler query = new StringBundler(3);
10092    
10093                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10094    
10095                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10096    
10097                    boolean bindArticleId = false;
10098    
10099                    if (articleId == null) {
10100                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10101                    }
10102                    else if (articleId.equals(StringPool.BLANK)) {
10103                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10104                    }
10105                    else {
10106                            bindArticleId = true;
10107    
10108                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10109                    }
10110    
10111                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10112                                    JournalArticle.class.getName(),
10113                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10114    
10115                    Session session = null;
10116    
10117                    try {
10118                            session = openSession();
10119    
10120                            SQLQuery q = session.createSQLQuery(sql);
10121    
10122                            q.addScalar(COUNT_COLUMN_NAME,
10123                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10124    
10125                            QueryPos qPos = QueryPos.getInstance(q);
10126    
10127                            qPos.add(groupId);
10128    
10129                            if (bindArticleId) {
10130                                    qPos.add(articleId);
10131                            }
10132    
10133                            Long count = (Long)q.uniqueResult();
10134    
10135                            return count.intValue();
10136                    }
10137                    catch (Exception e) {
10138                            throw processException(e);
10139                    }
10140                    finally {
10141                            closeSession(session);
10142                    }
10143            }
10144    
10145            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
10146            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
10147            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
10148            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
10149            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10150                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10151                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10152                            "findByG_UT",
10153                            new String[] {
10154                                    Long.class.getName(), String.class.getName(),
10155                                    
10156                            Integer.class.getName(), Integer.class.getName(),
10157                                    OrderByComparator.class.getName()
10158                            });
10159            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10160                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10161                            JournalArticleImpl.class,
10162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
10163                            new String[] { Long.class.getName(), String.class.getName() },
10164                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10165                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
10166                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10167                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10168            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10169                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10170                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
10171                            new String[] { Long.class.getName(), String.class.getName() });
10172    
10173            /**
10174             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
10175             *
10176             * @param groupId the group ID
10177             * @param urlTitle the url title
10178             * @return the matching journal articles
10179             * @throws SystemException if a system exception occurred
10180             */
10181            @Override
10182            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
10183                    throws SystemException {
10184                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10185                            QueryUtil.ALL_POS, null);
10186            }
10187    
10188            /**
10189             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10190             *
10191             * <p>
10192             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10193             * </p>
10194             *
10195             * @param groupId the group ID
10196             * @param urlTitle the url title
10197             * @param start the lower bound of the range of journal articles
10198             * @param end the upper bound of the range of journal articles (not inclusive)
10199             * @return the range of matching journal articles
10200             * @throws SystemException if a system exception occurred
10201             */
10202            @Override
10203            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10204                    int start, int end) throws SystemException {
10205                    return findByG_UT(groupId, urlTitle, start, end, null);
10206            }
10207    
10208            /**
10209             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10210             *
10211             * <p>
10212             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10213             * </p>
10214             *
10215             * @param groupId the group ID
10216             * @param urlTitle the url title
10217             * @param start the lower bound of the range of journal articles
10218             * @param end the upper bound of the range of journal articles (not inclusive)
10219             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10220             * @return the ordered range of matching journal articles
10221             * @throws SystemException if a system exception occurred
10222             */
10223            @Override
10224            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10225                    int start, int end, OrderByComparator orderByComparator)
10226                    throws SystemException {
10227                    boolean pagination = true;
10228                    FinderPath finderPath = null;
10229                    Object[] finderArgs = null;
10230    
10231                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10232                                    (orderByComparator == null)) {
10233                            pagination = false;
10234                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
10235                            finderArgs = new Object[] { groupId, urlTitle };
10236                    }
10237                    else {
10238                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
10239                            finderArgs = new Object[] {
10240                                            groupId, urlTitle,
10241                                            
10242                                            start, end, orderByComparator
10243                                    };
10244                    }
10245    
10246                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10247                                    finderArgs, this);
10248    
10249                    if ((list != null) && !list.isEmpty()) {
10250                            for (JournalArticle journalArticle : list) {
10251                                    if ((groupId != journalArticle.getGroupId()) ||
10252                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
10253                                            list = null;
10254    
10255                                            break;
10256                                    }
10257                            }
10258                    }
10259    
10260                    if (list == null) {
10261                            StringBundler query = null;
10262    
10263                            if (orderByComparator != null) {
10264                                    query = new StringBundler(4 +
10265                                                    (orderByComparator.getOrderByFields().length * 3));
10266                            }
10267                            else {
10268                                    query = new StringBundler(4);
10269                            }
10270    
10271                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10272    
10273                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10274    
10275                            boolean bindUrlTitle = false;
10276    
10277                            if (urlTitle == null) {
10278                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10279                            }
10280                            else if (urlTitle.equals(StringPool.BLANK)) {
10281                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10282                            }
10283                            else {
10284                                    bindUrlTitle = true;
10285    
10286                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10287                            }
10288    
10289                            if (orderByComparator != null) {
10290                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10291                                            orderByComparator);
10292                            }
10293                            else
10294                             if (pagination) {
10295                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10296                            }
10297    
10298                            String sql = query.toString();
10299    
10300                            Session session = null;
10301    
10302                            try {
10303                                    session = openSession();
10304    
10305                                    Query q = session.createQuery(sql);
10306    
10307                                    QueryPos qPos = QueryPos.getInstance(q);
10308    
10309                                    qPos.add(groupId);
10310    
10311                                    if (bindUrlTitle) {
10312                                            qPos.add(urlTitle);
10313                                    }
10314    
10315                                    if (!pagination) {
10316                                            list = (List<JournalArticle>)QueryUtil.list(q,
10317                                                            getDialect(), start, end, false);
10318    
10319                                            Collections.sort(list);
10320    
10321                                            list = new UnmodifiableList<JournalArticle>(list);
10322                                    }
10323                                    else {
10324                                            list = (List<JournalArticle>)QueryUtil.list(q,
10325                                                            getDialect(), start, end);
10326                                    }
10327    
10328                                    cacheResult(list);
10329    
10330                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10331                            }
10332                            catch (Exception e) {
10333                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10334    
10335                                    throw processException(e);
10336                            }
10337                            finally {
10338                                    closeSession(session);
10339                            }
10340                    }
10341    
10342                    return list;
10343            }
10344    
10345            /**
10346             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10347             *
10348             * @param groupId the group ID
10349             * @param urlTitle the url title
10350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10351             * @return the first matching journal article
10352             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10353             * @throws SystemException if a system exception occurred
10354             */
10355            @Override
10356            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
10357                    OrderByComparator orderByComparator)
10358                    throws NoSuchArticleException, SystemException {
10359                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
10360                                    orderByComparator);
10361    
10362                    if (journalArticle != null) {
10363                            return journalArticle;
10364                    }
10365    
10366                    StringBundler msg = new StringBundler(6);
10367    
10368                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10369    
10370                    msg.append("groupId=");
10371                    msg.append(groupId);
10372    
10373                    msg.append(", urlTitle=");
10374                    msg.append(urlTitle);
10375    
10376                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10377    
10378                    throw new NoSuchArticleException(msg.toString());
10379            }
10380    
10381            /**
10382             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10383             *
10384             * @param groupId the group ID
10385             * @param urlTitle the url title
10386             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10387             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10388             * @throws SystemException if a system exception occurred
10389             */
10390            @Override
10391            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
10392                    OrderByComparator orderByComparator) throws SystemException {
10393                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
10394                                    orderByComparator);
10395    
10396                    if (!list.isEmpty()) {
10397                            return list.get(0);
10398                    }
10399    
10400                    return null;
10401            }
10402    
10403            /**
10404             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10405             *
10406             * @param groupId the group ID
10407             * @param urlTitle the url title
10408             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10409             * @return the last matching journal article
10410             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10411             * @throws SystemException if a system exception occurred
10412             */
10413            @Override
10414            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
10415                    OrderByComparator orderByComparator)
10416                    throws NoSuchArticleException, SystemException {
10417                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
10418                                    orderByComparator);
10419    
10420                    if (journalArticle != null) {
10421                            return journalArticle;
10422                    }
10423    
10424                    StringBundler msg = new StringBundler(6);
10425    
10426                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10427    
10428                    msg.append("groupId=");
10429                    msg.append(groupId);
10430    
10431                    msg.append(", urlTitle=");
10432                    msg.append(urlTitle);
10433    
10434                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10435    
10436                    throw new NoSuchArticleException(msg.toString());
10437            }
10438    
10439            /**
10440             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10441             *
10442             * @param groupId the group ID
10443             * @param urlTitle the url title
10444             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10445             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10446             * @throws SystemException if a system exception occurred
10447             */
10448            @Override
10449            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
10450                    OrderByComparator orderByComparator) throws SystemException {
10451                    int count = countByG_UT(groupId, urlTitle);
10452    
10453                    if (count == 0) {
10454                            return null;
10455                    }
10456    
10457                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
10458                                    count, orderByComparator);
10459    
10460                    if (!list.isEmpty()) {
10461                            return list.get(0);
10462                    }
10463    
10464                    return null;
10465            }
10466    
10467            /**
10468             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10469             *
10470             * @param id the primary key of the current journal article
10471             * @param groupId the group ID
10472             * @param urlTitle the url title
10473             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10474             * @return the previous, current, and next journal article
10475             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10476             * @throws SystemException if a system exception occurred
10477             */
10478            @Override
10479            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
10480                    String urlTitle, OrderByComparator orderByComparator)
10481                    throws NoSuchArticleException, SystemException {
10482                    JournalArticle journalArticle = findByPrimaryKey(id);
10483    
10484                    Session session = null;
10485    
10486                    try {
10487                            session = openSession();
10488    
10489                            JournalArticle[] array = new JournalArticleImpl[3];
10490    
10491                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10492                                            urlTitle, orderByComparator, true);
10493    
10494                            array[1] = journalArticle;
10495    
10496                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10497                                            urlTitle, orderByComparator, false);
10498    
10499                            return array;
10500                    }
10501                    catch (Exception e) {
10502                            throw processException(e);
10503                    }
10504                    finally {
10505                            closeSession(session);
10506                    }
10507            }
10508    
10509            protected JournalArticle getByG_UT_PrevAndNext(Session session,
10510                    JournalArticle journalArticle, long groupId, String urlTitle,
10511                    OrderByComparator orderByComparator, boolean previous) {
10512                    StringBundler query = null;
10513    
10514                    if (orderByComparator != null) {
10515                            query = new StringBundler(6 +
10516                                            (orderByComparator.getOrderByFields().length * 6));
10517                    }
10518                    else {
10519                            query = new StringBundler(3);
10520                    }
10521    
10522                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10523    
10524                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10525    
10526                    boolean bindUrlTitle = false;
10527    
10528                    if (urlTitle == null) {
10529                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10530                    }
10531                    else if (urlTitle.equals(StringPool.BLANK)) {
10532                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10533                    }
10534                    else {
10535                            bindUrlTitle = true;
10536    
10537                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10538                    }
10539    
10540                    if (orderByComparator != null) {
10541                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10542    
10543                            if (orderByConditionFields.length > 0) {
10544                                    query.append(WHERE_AND);
10545                            }
10546    
10547                            for (int i = 0; i < orderByConditionFields.length; i++) {
10548                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10549                                    query.append(orderByConditionFields[i]);
10550    
10551                                    if ((i + 1) < orderByConditionFields.length) {
10552                                            if (orderByComparator.isAscending() ^ previous) {
10553                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10554                                            }
10555                                            else {
10556                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10557                                            }
10558                                    }
10559                                    else {
10560                                            if (orderByComparator.isAscending() ^ previous) {
10561                                                    query.append(WHERE_GREATER_THAN);
10562                                            }
10563                                            else {
10564                                                    query.append(WHERE_LESSER_THAN);
10565                                            }
10566                                    }
10567                            }
10568    
10569                            query.append(ORDER_BY_CLAUSE);
10570    
10571                            String[] orderByFields = orderByComparator.getOrderByFields();
10572    
10573                            for (int i = 0; i < orderByFields.length; i++) {
10574                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10575                                    query.append(orderByFields[i]);
10576    
10577                                    if ((i + 1) < orderByFields.length) {
10578                                            if (orderByComparator.isAscending() ^ previous) {
10579                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10580                                            }
10581                                            else {
10582                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10583                                            }
10584                                    }
10585                                    else {
10586                                            if (orderByComparator.isAscending() ^ previous) {
10587                                                    query.append(ORDER_BY_ASC);
10588                                            }
10589                                            else {
10590                                                    query.append(ORDER_BY_DESC);
10591                                            }
10592                                    }
10593                            }
10594                    }
10595                    else {
10596                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10597                    }
10598    
10599                    String sql = query.toString();
10600    
10601                    Query q = session.createQuery(sql);
10602    
10603                    q.setFirstResult(0);
10604                    q.setMaxResults(2);
10605    
10606                    QueryPos qPos = QueryPos.getInstance(q);
10607    
10608                    qPos.add(groupId);
10609    
10610                    if (bindUrlTitle) {
10611                            qPos.add(urlTitle);
10612                    }
10613    
10614                    if (orderByComparator != null) {
10615                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10616    
10617                            for (Object value : values) {
10618                                    qPos.add(value);
10619                            }
10620                    }
10621    
10622                    List<JournalArticle> list = q.list();
10623    
10624                    if (list.size() == 2) {
10625                            return list.get(1);
10626                    }
10627                    else {
10628                            return null;
10629                    }
10630            }
10631    
10632            /**
10633             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10634             *
10635             * @param groupId the group ID
10636             * @param urlTitle the url title
10637             * @return the matching journal articles that the user has permission to view
10638             * @throws SystemException if a system exception occurred
10639             */
10640            @Override
10641            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
10642                    throws SystemException {
10643                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10644                            QueryUtil.ALL_POS, null);
10645            }
10646    
10647            /**
10648             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10649             *
10650             * <p>
10651             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10652             * </p>
10653             *
10654             * @param groupId the group ID
10655             * @param urlTitle the url title
10656             * @param start the lower bound of the range of journal articles
10657             * @param end the upper bound of the range of journal articles (not inclusive)
10658             * @return the range of matching journal articles that the user has permission to view
10659             * @throws SystemException if a system exception occurred
10660             */
10661            @Override
10662            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10663                    int start, int end) throws SystemException {
10664                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
10665            }
10666    
10667            /**
10668             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
10669             *
10670             * <p>
10671             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10672             * </p>
10673             *
10674             * @param groupId the group ID
10675             * @param urlTitle the url title
10676             * @param start the lower bound of the range of journal articles
10677             * @param end the upper bound of the range of journal articles (not inclusive)
10678             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10679             * @return the ordered range of matching journal articles that the user has permission to view
10680             * @throws SystemException if a system exception occurred
10681             */
10682            @Override
10683            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10684                    int start, int end, OrderByComparator orderByComparator)
10685                    throws SystemException {
10686                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10687                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
10688                    }
10689    
10690                    StringBundler query = null;
10691    
10692                    if (orderByComparator != null) {
10693                            query = new StringBundler(4 +
10694                                            (orderByComparator.getOrderByFields().length * 3));
10695                    }
10696                    else {
10697                            query = new StringBundler(4);
10698                    }
10699    
10700                    if (getDB().isSupportsInlineDistinct()) {
10701                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10702                    }
10703                    else {
10704                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10705                    }
10706    
10707                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10708    
10709                    boolean bindUrlTitle = false;
10710    
10711                    if (urlTitle == null) {
10712                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10713                    }
10714                    else if (urlTitle.equals(StringPool.BLANK)) {
10715                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10716                    }
10717                    else {
10718                            bindUrlTitle = true;
10719    
10720                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10721                    }
10722    
10723                    if (!getDB().isSupportsInlineDistinct()) {
10724                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10725                    }
10726    
10727                    if (orderByComparator != null) {
10728                            if (getDB().isSupportsInlineDistinct()) {
10729                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10730                                            orderByComparator, true);
10731                            }
10732                            else {
10733                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10734                                            orderByComparator, true);
10735                            }
10736                    }
10737                    else {
10738                            if (getDB().isSupportsInlineDistinct()) {
10739                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10740                            }
10741                            else {
10742                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10743                            }
10744                    }
10745    
10746                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10747                                    JournalArticle.class.getName(),
10748                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10749    
10750                    Session session = null;
10751    
10752                    try {
10753                            session = openSession();
10754    
10755                            SQLQuery q = session.createSQLQuery(sql);
10756    
10757                            if (getDB().isSupportsInlineDistinct()) {
10758                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10759                            }
10760                            else {
10761                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10762                            }
10763    
10764                            QueryPos qPos = QueryPos.getInstance(q);
10765    
10766                            qPos.add(groupId);
10767    
10768                            if (bindUrlTitle) {
10769                                    qPos.add(urlTitle);
10770                            }
10771    
10772                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10773                                    end);
10774                    }
10775                    catch (Exception e) {
10776                            throw processException(e);
10777                    }
10778                    finally {
10779                            closeSession(session);
10780                    }
10781            }
10782    
10783            /**
10784             * 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;.
10785             *
10786             * @param id the primary key of the current journal article
10787             * @param groupId the group ID
10788             * @param urlTitle the url title
10789             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10790             * @return the previous, current, and next journal article
10791             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10792             * @throws SystemException if a system exception occurred
10793             */
10794            @Override
10795            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
10796                    String urlTitle, OrderByComparator orderByComparator)
10797                    throws NoSuchArticleException, SystemException {
10798                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10799                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
10800                                    orderByComparator);
10801                    }
10802    
10803                    JournalArticle journalArticle = findByPrimaryKey(id);
10804    
10805                    Session session = null;
10806    
10807                    try {
10808                            session = openSession();
10809    
10810                            JournalArticle[] array = new JournalArticleImpl[3];
10811    
10812                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10813                                            groupId, urlTitle, orderByComparator, true);
10814    
10815                            array[1] = journalArticle;
10816    
10817                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10818                                            groupId, urlTitle, orderByComparator, false);
10819    
10820                            return array;
10821                    }
10822                    catch (Exception e) {
10823                            throw processException(e);
10824                    }
10825                    finally {
10826                            closeSession(session);
10827                    }
10828            }
10829    
10830            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
10831                    JournalArticle journalArticle, long groupId, String urlTitle,
10832                    OrderByComparator orderByComparator, boolean previous) {
10833                    StringBundler query = null;
10834    
10835                    if (orderByComparator != null) {
10836                            query = new StringBundler(6 +
10837                                            (orderByComparator.getOrderByFields().length * 6));
10838                    }
10839                    else {
10840                            query = new StringBundler(3);
10841                    }
10842    
10843                    if (getDB().isSupportsInlineDistinct()) {
10844                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10845                    }
10846                    else {
10847                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10848                    }
10849    
10850                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10851    
10852                    boolean bindUrlTitle = false;
10853    
10854                    if (urlTitle == null) {
10855                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10856                    }
10857                    else if (urlTitle.equals(StringPool.BLANK)) {
10858                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10859                    }
10860                    else {
10861                            bindUrlTitle = true;
10862    
10863                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10864                    }
10865    
10866                    if (!getDB().isSupportsInlineDistinct()) {
10867                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10868                    }
10869    
10870                    if (orderByComparator != null) {
10871                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10872    
10873                            if (orderByConditionFields.length > 0) {
10874                                    query.append(WHERE_AND);
10875                            }
10876    
10877                            for (int i = 0; i < orderByConditionFields.length; i++) {
10878                                    if (getDB().isSupportsInlineDistinct()) {
10879                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10880                                    }
10881                                    else {
10882                                            query.append(_ORDER_BY_ENTITY_TABLE);
10883                                    }
10884    
10885                                    query.append(orderByConditionFields[i]);
10886    
10887                                    if ((i + 1) < orderByConditionFields.length) {
10888                                            if (orderByComparator.isAscending() ^ previous) {
10889                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10890                                            }
10891                                            else {
10892                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10893                                            }
10894                                    }
10895                                    else {
10896                                            if (orderByComparator.isAscending() ^ previous) {
10897                                                    query.append(WHERE_GREATER_THAN);
10898                                            }
10899                                            else {
10900                                                    query.append(WHERE_LESSER_THAN);
10901                                            }
10902                                    }
10903                            }
10904    
10905                            query.append(ORDER_BY_CLAUSE);
10906    
10907                            String[] orderByFields = orderByComparator.getOrderByFields();
10908    
10909                            for (int i = 0; i < orderByFields.length; i++) {
10910                                    if (getDB().isSupportsInlineDistinct()) {
10911                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10912                                    }
10913                                    else {
10914                                            query.append(_ORDER_BY_ENTITY_TABLE);
10915                                    }
10916    
10917                                    query.append(orderByFields[i]);
10918    
10919                                    if ((i + 1) < orderByFields.length) {
10920                                            if (orderByComparator.isAscending() ^ previous) {
10921                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10922                                            }
10923                                            else {
10924                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10925                                            }
10926                                    }
10927                                    else {
10928                                            if (orderByComparator.isAscending() ^ previous) {
10929                                                    query.append(ORDER_BY_ASC);
10930                                            }
10931                                            else {
10932                                                    query.append(ORDER_BY_DESC);
10933                                            }
10934                                    }
10935                            }
10936                    }
10937                    else {
10938                            if (getDB().isSupportsInlineDistinct()) {
10939                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10940                            }
10941                            else {
10942                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10943                            }
10944                    }
10945    
10946                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10947                                    JournalArticle.class.getName(),
10948                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10949    
10950                    SQLQuery q = session.createSQLQuery(sql);
10951    
10952                    q.setFirstResult(0);
10953                    q.setMaxResults(2);
10954    
10955                    if (getDB().isSupportsInlineDistinct()) {
10956                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10957                    }
10958                    else {
10959                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10960                    }
10961    
10962                    QueryPos qPos = QueryPos.getInstance(q);
10963    
10964                    qPos.add(groupId);
10965    
10966                    if (bindUrlTitle) {
10967                            qPos.add(urlTitle);
10968                    }
10969    
10970                    if (orderByComparator != null) {
10971                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10972    
10973                            for (Object value : values) {
10974                                    qPos.add(value);
10975                            }
10976                    }
10977    
10978                    List<JournalArticle> list = q.list();
10979    
10980                    if (list.size() == 2) {
10981                            return list.get(1);
10982                    }
10983                    else {
10984                            return null;
10985                    }
10986            }
10987    
10988            /**
10989             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
10990             *
10991             * @param groupId the group ID
10992             * @param urlTitle the url title
10993             * @throws SystemException if a system exception occurred
10994             */
10995            @Override
10996            public void removeByG_UT(long groupId, String urlTitle)
10997                    throws SystemException {
10998                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
10999                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11000                            remove(journalArticle);
11001                    }
11002            }
11003    
11004            /**
11005             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
11006             *
11007             * @param groupId the group ID
11008             * @param urlTitle the url title
11009             * @return the number of matching journal articles
11010             * @throws SystemException if a system exception occurred
11011             */
11012            @Override
11013            public int countByG_UT(long groupId, String urlTitle)
11014                    throws SystemException {
11015                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
11016    
11017                    Object[] finderArgs = new Object[] { groupId, urlTitle };
11018    
11019                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11020                                    this);
11021    
11022                    if (count == null) {
11023                            StringBundler query = new StringBundler(3);
11024    
11025                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11026    
11027                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11028    
11029                            boolean bindUrlTitle = false;
11030    
11031                            if (urlTitle == null) {
11032                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11033                            }
11034                            else if (urlTitle.equals(StringPool.BLANK)) {
11035                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11036                            }
11037                            else {
11038                                    bindUrlTitle = true;
11039    
11040                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11041                            }
11042    
11043                            String sql = query.toString();
11044    
11045                            Session session = null;
11046    
11047                            try {
11048                                    session = openSession();
11049    
11050                                    Query q = session.createQuery(sql);
11051    
11052                                    QueryPos qPos = QueryPos.getInstance(q);
11053    
11054                                    qPos.add(groupId);
11055    
11056                                    if (bindUrlTitle) {
11057                                            qPos.add(urlTitle);
11058                                    }
11059    
11060                                    count = (Long)q.uniqueResult();
11061    
11062                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11063                            }
11064                            catch (Exception e) {
11065                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11066    
11067                                    throw processException(e);
11068                            }
11069                            finally {
11070                                    closeSession(session);
11071                            }
11072                    }
11073    
11074                    return count.intValue();
11075            }
11076    
11077            /**
11078             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
11079             *
11080             * @param groupId the group ID
11081             * @param urlTitle the url title
11082             * @return the number of matching journal articles that the user has permission to view
11083             * @throws SystemException if a system exception occurred
11084             */
11085            @Override
11086            public int filterCountByG_UT(long groupId, String urlTitle)
11087                    throws SystemException {
11088                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11089                            return countByG_UT(groupId, urlTitle);
11090                    }
11091    
11092                    StringBundler query = new StringBundler(3);
11093    
11094                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11095    
11096                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11097    
11098                    boolean bindUrlTitle = false;
11099    
11100                    if (urlTitle == null) {
11101                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11102                    }
11103                    else if (urlTitle.equals(StringPool.BLANK)) {
11104                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11105                    }
11106                    else {
11107                            bindUrlTitle = true;
11108    
11109                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11110                    }
11111    
11112                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11113                                    JournalArticle.class.getName(),
11114                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11115    
11116                    Session session = null;
11117    
11118                    try {
11119                            session = openSession();
11120    
11121                            SQLQuery q = session.createSQLQuery(sql);
11122    
11123                            q.addScalar(COUNT_COLUMN_NAME,
11124                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11125    
11126                            QueryPos qPos = QueryPos.getInstance(q);
11127    
11128                            qPos.add(groupId);
11129    
11130                            if (bindUrlTitle) {
11131                                    qPos.add(urlTitle);
11132                            }
11133    
11134                            Long count = (Long)q.uniqueResult();
11135    
11136                            return count.intValue();
11137                    }
11138                    catch (Exception e) {
11139                            throw processException(e);
11140                    }
11141                    finally {
11142                            closeSession(session);
11143                    }
11144            }
11145    
11146            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
11147            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
11148            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
11149            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
11150            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11151                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11152                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11153                            "findByG_S",
11154                            new String[] {
11155                                    Long.class.getName(), String.class.getName(),
11156                                    
11157                            Integer.class.getName(), Integer.class.getName(),
11158                                    OrderByComparator.class.getName()
11159                            });
11160            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11161                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11162                            JournalArticleImpl.class,
11163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
11164                            new String[] { Long.class.getName(), String.class.getName() },
11165                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11166                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
11167                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11168                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11169            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11170                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11171                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
11172                            new String[] { Long.class.getName(), String.class.getName() });
11173    
11174            /**
11175             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
11176             *
11177             * @param groupId the group ID
11178             * @param structureId the structure ID
11179             * @return the matching journal articles
11180             * @throws SystemException if a system exception occurred
11181             */
11182            @Override
11183            public List<JournalArticle> findByG_S(long groupId, String structureId)
11184                    throws SystemException {
11185                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
11186                            QueryUtil.ALL_POS, null);
11187            }
11188    
11189            /**
11190             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
11191             *
11192             * <p>
11193             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11194             * </p>
11195             *
11196             * @param groupId the group ID
11197             * @param structureId the structure ID
11198             * @param start the lower bound of the range of journal articles
11199             * @param end the upper bound of the range of journal articles (not inclusive)
11200             * @return the range of matching journal articles
11201             * @throws SystemException if a system exception occurred
11202             */
11203            @Override
11204            public List<JournalArticle> findByG_S(long groupId, String structureId,
11205                    int start, int end) throws SystemException {
11206                    return findByG_S(groupId, structureId, start, end, null);
11207            }
11208    
11209            /**
11210             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
11211             *
11212             * <p>
11213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11214             * </p>
11215             *
11216             * @param groupId the group ID
11217             * @param structureId the structure ID
11218             * @param start the lower bound of the range of journal articles
11219             * @param end the upper bound of the range of journal articles (not inclusive)
11220             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11221             * @return the ordered range of matching journal articles
11222             * @throws SystemException if a system exception occurred
11223             */
11224            @Override
11225            public List<JournalArticle> findByG_S(long groupId, String structureId,
11226                    int start, int end, OrderByComparator orderByComparator)
11227                    throws SystemException {
11228                    boolean pagination = true;
11229                    FinderPath finderPath = null;
11230                    Object[] finderArgs = null;
11231    
11232                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11233                                    (orderByComparator == null)) {
11234                            pagination = false;
11235                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
11236                            finderArgs = new Object[] { groupId, structureId };
11237                    }
11238                    else {
11239                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
11240                            finderArgs = new Object[] {
11241                                            groupId, structureId,
11242                                            
11243                                            start, end, orderByComparator
11244                                    };
11245                    }
11246    
11247                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11248                                    finderArgs, this);
11249    
11250                    if ((list != null) && !list.isEmpty()) {
11251                            for (JournalArticle journalArticle : list) {
11252                                    if ((groupId != journalArticle.getGroupId()) ||
11253                                                    !Validator.equals(structureId,
11254                                                            journalArticle.getStructureId())) {
11255                                            list = null;
11256    
11257                                            break;
11258                                    }
11259                            }
11260                    }
11261    
11262                    if (list == null) {
11263                            StringBundler query = null;
11264    
11265                            if (orderByComparator != null) {
11266                                    query = new StringBundler(4 +
11267                                                    (orderByComparator.getOrderByFields().length * 3));
11268                            }
11269                            else {
11270                                    query = new StringBundler(4);
11271                            }
11272    
11273                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11274    
11275                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11276    
11277                            boolean bindStructureId = false;
11278    
11279                            if (structureId == null) {
11280                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11281                            }
11282                            else if (structureId.equals(StringPool.BLANK)) {
11283                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11284                            }
11285                            else {
11286                                    bindStructureId = true;
11287    
11288                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11289                            }
11290    
11291                            if (orderByComparator != null) {
11292                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11293                                            orderByComparator);
11294                            }
11295                            else
11296                             if (pagination) {
11297                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11298                            }
11299    
11300                            String sql = query.toString();
11301    
11302                            Session session = null;
11303    
11304                            try {
11305                                    session = openSession();
11306    
11307                                    Query q = session.createQuery(sql);
11308    
11309                                    QueryPos qPos = QueryPos.getInstance(q);
11310    
11311                                    qPos.add(groupId);
11312    
11313                                    if (bindStructureId) {
11314                                            qPos.add(structureId);
11315                                    }
11316    
11317                                    if (!pagination) {
11318                                            list = (List<JournalArticle>)QueryUtil.list(q,
11319                                                            getDialect(), start, end, false);
11320    
11321                                            Collections.sort(list);
11322    
11323                                            list = new UnmodifiableList<JournalArticle>(list);
11324                                    }
11325                                    else {
11326                                            list = (List<JournalArticle>)QueryUtil.list(q,
11327                                                            getDialect(), start, end);
11328                                    }
11329    
11330                                    cacheResult(list);
11331    
11332                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11333                            }
11334                            catch (Exception e) {
11335                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11336    
11337                                    throw processException(e);
11338                            }
11339                            finally {
11340                                    closeSession(session);
11341                            }
11342                    }
11343    
11344                    return list;
11345            }
11346    
11347            /**
11348             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11349             *
11350             * @param groupId the group ID
11351             * @param structureId the structure ID
11352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11353             * @return the first matching journal article
11354             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11355             * @throws SystemException if a system exception occurred
11356             */
11357            @Override
11358            public JournalArticle findByG_S_First(long groupId, String structureId,
11359                    OrderByComparator orderByComparator)
11360                    throws NoSuchArticleException, SystemException {
11361                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
11362                                    orderByComparator);
11363    
11364                    if (journalArticle != null) {
11365                            return journalArticle;
11366                    }
11367    
11368                    StringBundler msg = new StringBundler(6);
11369    
11370                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11371    
11372                    msg.append("groupId=");
11373                    msg.append(groupId);
11374    
11375                    msg.append(", structureId=");
11376                    msg.append(structureId);
11377    
11378                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11379    
11380                    throw new NoSuchArticleException(msg.toString());
11381            }
11382    
11383            /**
11384             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11385             *
11386             * @param groupId the group ID
11387             * @param structureId the structure ID
11388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11389             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11390             * @throws SystemException if a system exception occurred
11391             */
11392            @Override
11393            public JournalArticle fetchByG_S_First(long groupId, String structureId,
11394                    OrderByComparator orderByComparator) throws SystemException {
11395                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
11396                                    orderByComparator);
11397    
11398                    if (!list.isEmpty()) {
11399                            return list.get(0);
11400                    }
11401    
11402                    return null;
11403            }
11404    
11405            /**
11406             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11407             *
11408             * @param groupId the group ID
11409             * @param structureId the structure ID
11410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11411             * @return the last matching journal article
11412             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11413             * @throws SystemException if a system exception occurred
11414             */
11415            @Override
11416            public JournalArticle findByG_S_Last(long groupId, String structureId,
11417                    OrderByComparator orderByComparator)
11418                    throws NoSuchArticleException, SystemException {
11419                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
11420                                    orderByComparator);
11421    
11422                    if (journalArticle != null) {
11423                            return journalArticle;
11424                    }
11425    
11426                    StringBundler msg = new StringBundler(6);
11427    
11428                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11429    
11430                    msg.append("groupId=");
11431                    msg.append(groupId);
11432    
11433                    msg.append(", structureId=");
11434                    msg.append(structureId);
11435    
11436                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11437    
11438                    throw new NoSuchArticleException(msg.toString());
11439            }
11440    
11441            /**
11442             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11443             *
11444             * @param groupId the group ID
11445             * @param structureId the structure ID
11446             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11447             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11448             * @throws SystemException if a system exception occurred
11449             */
11450            @Override
11451            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
11452                    OrderByComparator orderByComparator) throws SystemException {
11453                    int count = countByG_S(groupId, structureId);
11454    
11455                    if (count == 0) {
11456                            return null;
11457                    }
11458    
11459                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
11460                                    count, orderByComparator);
11461    
11462                    if (!list.isEmpty()) {
11463                            return list.get(0);
11464                    }
11465    
11466                    return null;
11467            }
11468    
11469            /**
11470             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11471             *
11472             * @param id the primary key of the current journal article
11473             * @param groupId the group ID
11474             * @param structureId the structure ID
11475             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11476             * @return the previous, current, and next journal article
11477             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11478             * @throws SystemException if a system exception occurred
11479             */
11480            @Override
11481            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
11482                    String structureId, OrderByComparator orderByComparator)
11483                    throws NoSuchArticleException, SystemException {
11484                    JournalArticle journalArticle = findByPrimaryKey(id);
11485    
11486                    Session session = null;
11487    
11488                    try {
11489                            session = openSession();
11490    
11491                            JournalArticle[] array = new JournalArticleImpl[3];
11492    
11493                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11494                                            structureId, orderByComparator, true);
11495    
11496                            array[1] = journalArticle;
11497    
11498                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11499                                            structureId, orderByComparator, false);
11500    
11501                            return array;
11502                    }
11503                    catch (Exception e) {
11504                            throw processException(e);
11505                    }
11506                    finally {
11507                            closeSession(session);
11508                    }
11509            }
11510    
11511            protected JournalArticle getByG_S_PrevAndNext(Session session,
11512                    JournalArticle journalArticle, long groupId, String structureId,
11513                    OrderByComparator orderByComparator, boolean previous) {
11514                    StringBundler query = null;
11515    
11516                    if (orderByComparator != null) {
11517                            query = new StringBundler(6 +
11518                                            (orderByComparator.getOrderByFields().length * 6));
11519                    }
11520                    else {
11521                            query = new StringBundler(3);
11522                    }
11523    
11524                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11525    
11526                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11527    
11528                    boolean bindStructureId = false;
11529    
11530                    if (structureId == null) {
11531                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11532                    }
11533                    else if (structureId.equals(StringPool.BLANK)) {
11534                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11535                    }
11536                    else {
11537                            bindStructureId = true;
11538    
11539                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11540                    }
11541    
11542                    if (orderByComparator != null) {
11543                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11544    
11545                            if (orderByConditionFields.length > 0) {
11546                                    query.append(WHERE_AND);
11547                            }
11548    
11549                            for (int i = 0; i < orderByConditionFields.length; i++) {
11550                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11551                                    query.append(orderByConditionFields[i]);
11552    
11553                                    if ((i + 1) < orderByConditionFields.length) {
11554                                            if (orderByComparator.isAscending() ^ previous) {
11555                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11556                                            }
11557                                            else {
11558                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11559                                            }
11560                                    }
11561                                    else {
11562                                            if (orderByComparator.isAscending() ^ previous) {
11563                                                    query.append(WHERE_GREATER_THAN);
11564                                            }
11565                                            else {
11566                                                    query.append(WHERE_LESSER_THAN);
11567                                            }
11568                                    }
11569                            }
11570    
11571                            query.append(ORDER_BY_CLAUSE);
11572    
11573                            String[] orderByFields = orderByComparator.getOrderByFields();
11574    
11575                            for (int i = 0; i < orderByFields.length; i++) {
11576                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11577                                    query.append(orderByFields[i]);
11578    
11579                                    if ((i + 1) < orderByFields.length) {
11580                                            if (orderByComparator.isAscending() ^ previous) {
11581                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11582                                            }
11583                                            else {
11584                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11585                                            }
11586                                    }
11587                                    else {
11588                                            if (orderByComparator.isAscending() ^ previous) {
11589                                                    query.append(ORDER_BY_ASC);
11590                                            }
11591                                            else {
11592                                                    query.append(ORDER_BY_DESC);
11593                                            }
11594                                    }
11595                            }
11596                    }
11597                    else {
11598                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11599                    }
11600    
11601                    String sql = query.toString();
11602    
11603                    Query q = session.createQuery(sql);
11604    
11605                    q.setFirstResult(0);
11606                    q.setMaxResults(2);
11607    
11608                    QueryPos qPos = QueryPos.getInstance(q);
11609    
11610                    qPos.add(groupId);
11611    
11612                    if (bindStructureId) {
11613                            qPos.add(structureId);
11614                    }
11615    
11616                    if (orderByComparator != null) {
11617                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11618    
11619                            for (Object value : values) {
11620                                    qPos.add(value);
11621                            }
11622                    }
11623    
11624                    List<JournalArticle> list = q.list();
11625    
11626                    if (list.size() == 2) {
11627                            return list.get(1);
11628                    }
11629                    else {
11630                            return null;
11631                    }
11632            }
11633    
11634            /**
11635             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11636             *
11637             * @param groupId the group ID
11638             * @param structureId the structure ID
11639             * @return the matching journal articles that the user has permission to view
11640             * @throws SystemException if a system exception occurred
11641             */
11642            @Override
11643            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
11644                    throws SystemException {
11645                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
11646                            QueryUtil.ALL_POS, null);
11647            }
11648    
11649            /**
11650             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11651             *
11652             * <p>
11653             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11654             * </p>
11655             *
11656             * @param groupId the group ID
11657             * @param structureId the structure ID
11658             * @param start the lower bound of the range of journal articles
11659             * @param end the upper bound of the range of journal articles (not inclusive)
11660             * @return the range of matching journal articles that the user has permission to view
11661             * @throws SystemException if a system exception occurred
11662             */
11663            @Override
11664            public List<JournalArticle> filterFindByG_S(long groupId,
11665                    String structureId, int start, int end) throws SystemException {
11666                    return filterFindByG_S(groupId, structureId, start, end, null);
11667            }
11668    
11669            /**
11670             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
11671             *
11672             * <p>
11673             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11674             * </p>
11675             *
11676             * @param groupId the group ID
11677             * @param structureId the structure ID
11678             * @param start the lower bound of the range of journal articles
11679             * @param end the upper bound of the range of journal articles (not inclusive)
11680             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11681             * @return the ordered range of matching journal articles that the user has permission to view
11682             * @throws SystemException if a system exception occurred
11683             */
11684            @Override
11685            public List<JournalArticle> filterFindByG_S(long groupId,
11686                    String structureId, int start, int end,
11687                    OrderByComparator orderByComparator) throws SystemException {
11688                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11689                            return findByG_S(groupId, structureId, start, end, orderByComparator);
11690                    }
11691    
11692                    StringBundler query = null;
11693    
11694                    if (orderByComparator != null) {
11695                            query = new StringBundler(4 +
11696                                            (orderByComparator.getOrderByFields().length * 3));
11697                    }
11698                    else {
11699                            query = new StringBundler(4);
11700                    }
11701    
11702                    if (getDB().isSupportsInlineDistinct()) {
11703                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11704                    }
11705                    else {
11706                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11707                    }
11708    
11709                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11710    
11711                    boolean bindStructureId = false;
11712    
11713                    if (structureId == null) {
11714                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11715                    }
11716                    else if (structureId.equals(StringPool.BLANK)) {
11717                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11718                    }
11719                    else {
11720                            bindStructureId = true;
11721    
11722                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11723                    }
11724    
11725                    if (!getDB().isSupportsInlineDistinct()) {
11726                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11727                    }
11728    
11729                    if (orderByComparator != null) {
11730                            if (getDB().isSupportsInlineDistinct()) {
11731                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11732                                            orderByComparator, true);
11733                            }
11734                            else {
11735                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11736                                            orderByComparator, true);
11737                            }
11738                    }
11739                    else {
11740                            if (getDB().isSupportsInlineDistinct()) {
11741                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11742                            }
11743                            else {
11744                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11745                            }
11746                    }
11747    
11748                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11749                                    JournalArticle.class.getName(),
11750                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11751    
11752                    Session session = null;
11753    
11754                    try {
11755                            session = openSession();
11756    
11757                            SQLQuery q = session.createSQLQuery(sql);
11758    
11759                            if (getDB().isSupportsInlineDistinct()) {
11760                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11761                            }
11762                            else {
11763                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11764                            }
11765    
11766                            QueryPos qPos = QueryPos.getInstance(q);
11767    
11768                            qPos.add(groupId);
11769    
11770                            if (bindStructureId) {
11771                                    qPos.add(structureId);
11772                            }
11773    
11774                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11775                                    end);
11776                    }
11777                    catch (Exception e) {
11778                            throw processException(e);
11779                    }
11780                    finally {
11781                            closeSession(session);
11782                    }
11783            }
11784    
11785            /**
11786             * 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;.
11787             *
11788             * @param id the primary key of the current journal article
11789             * @param groupId the group ID
11790             * @param structureId the structure ID
11791             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11792             * @return the previous, current, and next journal article
11793             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11794             * @throws SystemException if a system exception occurred
11795             */
11796            @Override
11797            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
11798                    String structureId, OrderByComparator orderByComparator)
11799                    throws NoSuchArticleException, SystemException {
11800                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11801                            return findByG_S_PrevAndNext(id, groupId, structureId,
11802                                    orderByComparator);
11803                    }
11804    
11805                    JournalArticle journalArticle = findByPrimaryKey(id);
11806    
11807                    Session session = null;
11808    
11809                    try {
11810                            session = openSession();
11811    
11812                            JournalArticle[] array = new JournalArticleImpl[3];
11813    
11814                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
11815                                            groupId, structureId, orderByComparator, true);
11816    
11817                            array[1] = journalArticle;
11818    
11819                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
11820                                            groupId, structureId, orderByComparator, false);
11821    
11822                            return array;
11823                    }
11824                    catch (Exception e) {
11825                            throw processException(e);
11826                    }
11827                    finally {
11828                            closeSession(session);
11829                    }
11830            }
11831    
11832            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
11833                    JournalArticle journalArticle, long groupId, String structureId,
11834                    OrderByComparator orderByComparator, boolean previous) {
11835                    StringBundler query = null;
11836    
11837                    if (orderByComparator != null) {
11838                            query = new StringBundler(6 +
11839                                            (orderByComparator.getOrderByFields().length * 6));
11840                    }
11841                    else {
11842                            query = new StringBundler(3);
11843                    }
11844    
11845                    if (getDB().isSupportsInlineDistinct()) {
11846                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11847                    }
11848                    else {
11849                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11850                    }
11851    
11852                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11853    
11854                    boolean bindStructureId = false;
11855    
11856                    if (structureId == null) {
11857                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11858                    }
11859                    else if (structureId.equals(StringPool.BLANK)) {
11860                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11861                    }
11862                    else {
11863                            bindStructureId = true;
11864    
11865                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11866                    }
11867    
11868                    if (!getDB().isSupportsInlineDistinct()) {
11869                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11870                    }
11871    
11872                    if (orderByComparator != null) {
11873                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11874    
11875                            if (orderByConditionFields.length > 0) {
11876                                    query.append(WHERE_AND);
11877                            }
11878    
11879                            for (int i = 0; i < orderByConditionFields.length; i++) {
11880                                    if (getDB().isSupportsInlineDistinct()) {
11881                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11882                                    }
11883                                    else {
11884                                            query.append(_ORDER_BY_ENTITY_TABLE);
11885                                    }
11886    
11887                                    query.append(orderByConditionFields[i]);
11888    
11889                                    if ((i + 1) < orderByConditionFields.length) {
11890                                            if (orderByComparator.isAscending() ^ previous) {
11891                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11892                                            }
11893                                            else {
11894                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11895                                            }
11896                                    }
11897                                    else {
11898                                            if (orderByComparator.isAscending() ^ previous) {
11899                                                    query.append(WHERE_GREATER_THAN);
11900                                            }
11901                                            else {
11902                                                    query.append(WHERE_LESSER_THAN);
11903                                            }
11904                                    }
11905                            }
11906    
11907                            query.append(ORDER_BY_CLAUSE);
11908    
11909                            String[] orderByFields = orderByComparator.getOrderByFields();
11910    
11911                            for (int i = 0; i < orderByFields.length; i++) {
11912                                    if (getDB().isSupportsInlineDistinct()) {
11913                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11914                                    }
11915                                    else {
11916                                            query.append(_ORDER_BY_ENTITY_TABLE);
11917                                    }
11918    
11919                                    query.append(orderByFields[i]);
11920    
11921                                    if ((i + 1) < orderByFields.length) {
11922                                            if (orderByComparator.isAscending() ^ previous) {
11923                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11924                                            }
11925                                            else {
11926                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11927                                            }
11928                                    }
11929                                    else {
11930                                            if (orderByComparator.isAscending() ^ previous) {
11931                                                    query.append(ORDER_BY_ASC);
11932                                            }
11933                                            else {
11934                                                    query.append(ORDER_BY_DESC);
11935                                            }
11936                                    }
11937                            }
11938                    }
11939                    else {
11940                            if (getDB().isSupportsInlineDistinct()) {
11941                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11942                            }
11943                            else {
11944                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11945                            }
11946                    }
11947    
11948                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11949                                    JournalArticle.class.getName(),
11950                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11951    
11952                    SQLQuery q = session.createSQLQuery(sql);
11953    
11954                    q.setFirstResult(0);
11955                    q.setMaxResults(2);
11956    
11957                    if (getDB().isSupportsInlineDistinct()) {
11958                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11959                    }
11960                    else {
11961                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11962                    }
11963    
11964                    QueryPos qPos = QueryPos.getInstance(q);
11965    
11966                    qPos.add(groupId);
11967    
11968                    if (bindStructureId) {
11969                            qPos.add(structureId);
11970                    }
11971    
11972                    if (orderByComparator != null) {
11973                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11974    
11975                            for (Object value : values) {
11976                                    qPos.add(value);
11977                            }
11978                    }
11979    
11980                    List<JournalArticle> list = q.list();
11981    
11982                    if (list.size() == 2) {
11983                            return list.get(1);
11984                    }
11985                    else {
11986                            return null;
11987                    }
11988            }
11989    
11990            /**
11991             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
11992             *
11993             * @param groupId the group ID
11994             * @param structureId the structure ID
11995             * @throws SystemException if a system exception occurred
11996             */
11997            @Override
11998            public void removeByG_S(long groupId, String structureId)
11999                    throws SystemException {
12000                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
12001                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12002                            remove(journalArticle);
12003                    }
12004            }
12005    
12006            /**
12007             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
12008             *
12009             * @param groupId the group ID
12010             * @param structureId the structure ID
12011             * @return the number of matching journal articles
12012             * @throws SystemException if a system exception occurred
12013             */
12014            @Override
12015            public int countByG_S(long groupId, String structureId)
12016                    throws SystemException {
12017                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
12018    
12019                    Object[] finderArgs = new Object[] { groupId, structureId };
12020    
12021                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12022                                    this);
12023    
12024                    if (count == null) {
12025                            StringBundler query = new StringBundler(3);
12026    
12027                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12028    
12029                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12030    
12031                            boolean bindStructureId = false;
12032    
12033                            if (structureId == null) {
12034                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12035                            }
12036                            else if (structureId.equals(StringPool.BLANK)) {
12037                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12038                            }
12039                            else {
12040                                    bindStructureId = true;
12041    
12042                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12043                            }
12044    
12045                            String sql = query.toString();
12046    
12047                            Session session = null;
12048    
12049                            try {
12050                                    session = openSession();
12051    
12052                                    Query q = session.createQuery(sql);
12053    
12054                                    QueryPos qPos = QueryPos.getInstance(q);
12055    
12056                                    qPos.add(groupId);
12057    
12058                                    if (bindStructureId) {
12059                                            qPos.add(structureId);
12060                                    }
12061    
12062                                    count = (Long)q.uniqueResult();
12063    
12064                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12065                            }
12066                            catch (Exception e) {
12067                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12068    
12069                                    throw processException(e);
12070                            }
12071                            finally {
12072                                    closeSession(session);
12073                            }
12074                    }
12075    
12076                    return count.intValue();
12077            }
12078    
12079            /**
12080             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
12081             *
12082             * @param groupId the group ID
12083             * @param structureId the structure ID
12084             * @return the number of matching journal articles that the user has permission to view
12085             * @throws SystemException if a system exception occurred
12086             */
12087            @Override
12088            public int filterCountByG_S(long groupId, String structureId)
12089                    throws SystemException {
12090                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12091                            return countByG_S(groupId, structureId);
12092                    }
12093    
12094                    StringBundler query = new StringBundler(3);
12095    
12096                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12097    
12098                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12099    
12100                    boolean bindStructureId = false;
12101    
12102                    if (structureId == null) {
12103                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12104                    }
12105                    else if (structureId.equals(StringPool.BLANK)) {
12106                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12107                    }
12108                    else {
12109                            bindStructureId = true;
12110    
12111                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12112                    }
12113    
12114                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12115                                    JournalArticle.class.getName(),
12116                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12117    
12118                    Session session = null;
12119    
12120                    try {
12121                            session = openSession();
12122    
12123                            SQLQuery q = session.createSQLQuery(sql);
12124    
12125                            q.addScalar(COUNT_COLUMN_NAME,
12126                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12127    
12128                            QueryPos qPos = QueryPos.getInstance(q);
12129    
12130                            qPos.add(groupId);
12131    
12132                            if (bindStructureId) {
12133                                    qPos.add(structureId);
12134                            }
12135    
12136                            Long count = (Long)q.uniqueResult();
12137    
12138                            return count.intValue();
12139                    }
12140                    catch (Exception e) {
12141                            throw processException(e);
12142                    }
12143                    finally {
12144                            closeSession(session);
12145                    }
12146            }
12147    
12148            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
12149            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
12150            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
12151            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
12152            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12153                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12154                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12155                            "findByG_T",
12156                            new String[] {
12157                                    Long.class.getName(), String.class.getName(),
12158                                    
12159                            Integer.class.getName(), Integer.class.getName(),
12160                                    OrderByComparator.class.getName()
12161                            });
12162            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12163                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12164                            JournalArticleImpl.class,
12165                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
12166                            new String[] { Long.class.getName(), String.class.getName() },
12167                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12168                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
12169                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12170                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12171            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12172                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12173                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
12174                            new String[] { Long.class.getName(), String.class.getName() });
12175    
12176            /**
12177             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
12178             *
12179             * @param groupId the group ID
12180             * @param templateId the template ID
12181             * @return the matching journal articles
12182             * @throws SystemException if a system exception occurred
12183             */
12184            @Override
12185            public List<JournalArticle> findByG_T(long groupId, String templateId)
12186                    throws SystemException {
12187                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
12188                            QueryUtil.ALL_POS, null);
12189            }
12190    
12191            /**
12192             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
12193             *
12194             * <p>
12195             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12196             * </p>
12197             *
12198             * @param groupId the group ID
12199             * @param templateId the template ID
12200             * @param start the lower bound of the range of journal articles
12201             * @param end the upper bound of the range of journal articles (not inclusive)
12202             * @return the range of matching journal articles
12203             * @throws SystemException if a system exception occurred
12204             */
12205            @Override
12206            public List<JournalArticle> findByG_T(long groupId, String templateId,
12207                    int start, int end) throws SystemException {
12208                    return findByG_T(groupId, templateId, start, end, null);
12209            }
12210    
12211            /**
12212             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
12213             *
12214             * <p>
12215             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12216             * </p>
12217             *
12218             * @param groupId the group ID
12219             * @param templateId the template ID
12220             * @param start the lower bound of the range of journal articles
12221             * @param end the upper bound of the range of journal articles (not inclusive)
12222             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12223             * @return the ordered range of matching journal articles
12224             * @throws SystemException if a system exception occurred
12225             */
12226            @Override
12227            public List<JournalArticle> findByG_T(long groupId, String templateId,
12228                    int start, int end, OrderByComparator orderByComparator)
12229                    throws SystemException {
12230                    boolean pagination = true;
12231                    FinderPath finderPath = null;
12232                    Object[] finderArgs = null;
12233    
12234                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12235                                    (orderByComparator == null)) {
12236                            pagination = false;
12237                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
12238                            finderArgs = new Object[] { groupId, templateId };
12239                    }
12240                    else {
12241                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
12242                            finderArgs = new Object[] {
12243                                            groupId, templateId,
12244                                            
12245                                            start, end, orderByComparator
12246                                    };
12247                    }
12248    
12249                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12250                                    finderArgs, this);
12251    
12252                    if ((list != null) && !list.isEmpty()) {
12253                            for (JournalArticle journalArticle : list) {
12254                                    if ((groupId != journalArticle.getGroupId()) ||
12255                                                    !Validator.equals(templateId,
12256                                                            journalArticle.getTemplateId())) {
12257                                            list = null;
12258    
12259                                            break;
12260                                    }
12261                            }
12262                    }
12263    
12264                    if (list == null) {
12265                            StringBundler query = null;
12266    
12267                            if (orderByComparator != null) {
12268                                    query = new StringBundler(4 +
12269                                                    (orderByComparator.getOrderByFields().length * 3));
12270                            }
12271                            else {
12272                                    query = new StringBundler(4);
12273                            }
12274    
12275                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12276    
12277                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12278    
12279                            boolean bindTemplateId = false;
12280    
12281                            if (templateId == null) {
12282                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12283                            }
12284                            else if (templateId.equals(StringPool.BLANK)) {
12285                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12286                            }
12287                            else {
12288                                    bindTemplateId = true;
12289    
12290                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12291                            }
12292    
12293                            if (orderByComparator != null) {
12294                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12295                                            orderByComparator);
12296                            }
12297                            else
12298                             if (pagination) {
12299                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12300                            }
12301    
12302                            String sql = query.toString();
12303    
12304                            Session session = null;
12305    
12306                            try {
12307                                    session = openSession();
12308    
12309                                    Query q = session.createQuery(sql);
12310    
12311                                    QueryPos qPos = QueryPos.getInstance(q);
12312    
12313                                    qPos.add(groupId);
12314    
12315                                    if (bindTemplateId) {
12316                                            qPos.add(templateId);
12317                                    }
12318    
12319                                    if (!pagination) {
12320                                            list = (List<JournalArticle>)QueryUtil.list(q,
12321                                                            getDialect(), start, end, false);
12322    
12323                                            Collections.sort(list);
12324    
12325                                            list = new UnmodifiableList<JournalArticle>(list);
12326                                    }
12327                                    else {
12328                                            list = (List<JournalArticle>)QueryUtil.list(q,
12329                                                            getDialect(), start, end);
12330                                    }
12331    
12332                                    cacheResult(list);
12333    
12334                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12335                            }
12336                            catch (Exception e) {
12337                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12338    
12339                                    throw processException(e);
12340                            }
12341                            finally {
12342                                    closeSession(session);
12343                            }
12344                    }
12345    
12346                    return list;
12347            }
12348    
12349            /**
12350             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12351             *
12352             * @param groupId the group ID
12353             * @param templateId the template ID
12354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12355             * @return the first matching journal article
12356             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12357             * @throws SystemException if a system exception occurred
12358             */
12359            @Override
12360            public JournalArticle findByG_T_First(long groupId, String templateId,
12361                    OrderByComparator orderByComparator)
12362                    throws NoSuchArticleException, SystemException {
12363                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
12364                                    orderByComparator);
12365    
12366                    if (journalArticle != null) {
12367                            return journalArticle;
12368                    }
12369    
12370                    StringBundler msg = new StringBundler(6);
12371    
12372                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12373    
12374                    msg.append("groupId=");
12375                    msg.append(groupId);
12376    
12377                    msg.append(", templateId=");
12378                    msg.append(templateId);
12379    
12380                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12381    
12382                    throw new NoSuchArticleException(msg.toString());
12383            }
12384    
12385            /**
12386             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12387             *
12388             * @param groupId the group ID
12389             * @param templateId the template ID
12390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12391             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12392             * @throws SystemException if a system exception occurred
12393             */
12394            @Override
12395            public JournalArticle fetchByG_T_First(long groupId, String templateId,
12396                    OrderByComparator orderByComparator) throws SystemException {
12397                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
12398                                    orderByComparator);
12399    
12400                    if (!list.isEmpty()) {
12401                            return list.get(0);
12402                    }
12403    
12404                    return null;
12405            }
12406    
12407            /**
12408             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12409             *
12410             * @param groupId the group ID
12411             * @param templateId the template ID
12412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12413             * @return the last matching journal article
12414             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12415             * @throws SystemException if a system exception occurred
12416             */
12417            @Override
12418            public JournalArticle findByG_T_Last(long groupId, String templateId,
12419                    OrderByComparator orderByComparator)
12420                    throws NoSuchArticleException, SystemException {
12421                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
12422                                    orderByComparator);
12423    
12424                    if (journalArticle != null) {
12425                            return journalArticle;
12426                    }
12427    
12428                    StringBundler msg = new StringBundler(6);
12429    
12430                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12431    
12432                    msg.append("groupId=");
12433                    msg.append(groupId);
12434    
12435                    msg.append(", templateId=");
12436                    msg.append(templateId);
12437    
12438                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12439    
12440                    throw new NoSuchArticleException(msg.toString());
12441            }
12442    
12443            /**
12444             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12445             *
12446             * @param groupId the group ID
12447             * @param templateId the template ID
12448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12449             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12450             * @throws SystemException if a system exception occurred
12451             */
12452            @Override
12453            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
12454                    OrderByComparator orderByComparator) throws SystemException {
12455                    int count = countByG_T(groupId, templateId);
12456    
12457                    if (count == 0) {
12458                            return null;
12459                    }
12460    
12461                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
12462                                    count, orderByComparator);
12463    
12464                    if (!list.isEmpty()) {
12465                            return list.get(0);
12466                    }
12467    
12468                    return null;
12469            }
12470    
12471            /**
12472             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12473             *
12474             * @param id the primary key of the current journal article
12475             * @param groupId the group ID
12476             * @param templateId the template ID
12477             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12478             * @return the previous, current, and next journal article
12479             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12480             * @throws SystemException if a system exception occurred
12481             */
12482            @Override
12483            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
12484                    String templateId, OrderByComparator orderByComparator)
12485                    throws NoSuchArticleException, SystemException {
12486                    JournalArticle journalArticle = findByPrimaryKey(id);
12487    
12488                    Session session = null;
12489    
12490                    try {
12491                            session = openSession();
12492    
12493                            JournalArticle[] array = new JournalArticleImpl[3];
12494    
12495                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12496                                            templateId, orderByComparator, true);
12497    
12498                            array[1] = journalArticle;
12499    
12500                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12501                                            templateId, orderByComparator, false);
12502    
12503                            return array;
12504                    }
12505                    catch (Exception e) {
12506                            throw processException(e);
12507                    }
12508                    finally {
12509                            closeSession(session);
12510                    }
12511            }
12512    
12513            protected JournalArticle getByG_T_PrevAndNext(Session session,
12514                    JournalArticle journalArticle, long groupId, String templateId,
12515                    OrderByComparator orderByComparator, boolean previous) {
12516                    StringBundler query = null;
12517    
12518                    if (orderByComparator != null) {
12519                            query = new StringBundler(6 +
12520                                            (orderByComparator.getOrderByFields().length * 6));
12521                    }
12522                    else {
12523                            query = new StringBundler(3);
12524                    }
12525    
12526                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12527    
12528                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12529    
12530                    boolean bindTemplateId = false;
12531    
12532                    if (templateId == null) {
12533                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12534                    }
12535                    else if (templateId.equals(StringPool.BLANK)) {
12536                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12537                    }
12538                    else {
12539                            bindTemplateId = true;
12540    
12541                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12542                    }
12543    
12544                    if (orderByComparator != null) {
12545                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12546    
12547                            if (orderByConditionFields.length > 0) {
12548                                    query.append(WHERE_AND);
12549                            }
12550    
12551                            for (int i = 0; i < orderByConditionFields.length; i++) {
12552                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12553                                    query.append(orderByConditionFields[i]);
12554    
12555                                    if ((i + 1) < orderByConditionFields.length) {
12556                                            if (orderByComparator.isAscending() ^ previous) {
12557                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12558                                            }
12559                                            else {
12560                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12561                                            }
12562                                    }
12563                                    else {
12564                                            if (orderByComparator.isAscending() ^ previous) {
12565                                                    query.append(WHERE_GREATER_THAN);
12566                                            }
12567                                            else {
12568                                                    query.append(WHERE_LESSER_THAN);
12569                                            }
12570                                    }
12571                            }
12572    
12573                            query.append(ORDER_BY_CLAUSE);
12574    
12575                            String[] orderByFields = orderByComparator.getOrderByFields();
12576    
12577                            for (int i = 0; i < orderByFields.length; i++) {
12578                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12579                                    query.append(orderByFields[i]);
12580    
12581                                    if ((i + 1) < orderByFields.length) {
12582                                            if (orderByComparator.isAscending() ^ previous) {
12583                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12584                                            }
12585                                            else {
12586                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12587                                            }
12588                                    }
12589                                    else {
12590                                            if (orderByComparator.isAscending() ^ previous) {
12591                                                    query.append(ORDER_BY_ASC);
12592                                            }
12593                                            else {
12594                                                    query.append(ORDER_BY_DESC);
12595                                            }
12596                                    }
12597                            }
12598                    }
12599                    else {
12600                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12601                    }
12602    
12603                    String sql = query.toString();
12604    
12605                    Query q = session.createQuery(sql);
12606    
12607                    q.setFirstResult(0);
12608                    q.setMaxResults(2);
12609    
12610                    QueryPos qPos = QueryPos.getInstance(q);
12611    
12612                    qPos.add(groupId);
12613    
12614                    if (bindTemplateId) {
12615                            qPos.add(templateId);
12616                    }
12617    
12618                    if (orderByComparator != null) {
12619                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12620    
12621                            for (Object value : values) {
12622                                    qPos.add(value);
12623                            }
12624                    }
12625    
12626                    List<JournalArticle> list = q.list();
12627    
12628                    if (list.size() == 2) {
12629                            return list.get(1);
12630                    }
12631                    else {
12632                            return null;
12633                    }
12634            }
12635    
12636            /**
12637             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12638             *
12639             * @param groupId the group ID
12640             * @param templateId the template ID
12641             * @return the matching journal articles that the user has permission to view
12642             * @throws SystemException if a system exception occurred
12643             */
12644            @Override
12645            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
12646                    throws SystemException {
12647                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
12648                            QueryUtil.ALL_POS, null);
12649            }
12650    
12651            /**
12652             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12653             *
12654             * <p>
12655             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12656             * </p>
12657             *
12658             * @param groupId the group ID
12659             * @param templateId the template ID
12660             * @param start the lower bound of the range of journal articles
12661             * @param end the upper bound of the range of journal articles (not inclusive)
12662             * @return the range of matching journal articles that the user has permission to view
12663             * @throws SystemException if a system exception occurred
12664             */
12665            @Override
12666            public List<JournalArticle> filterFindByG_T(long groupId,
12667                    String templateId, int start, int end) throws SystemException {
12668                    return filterFindByG_T(groupId, templateId, start, end, null);
12669            }
12670    
12671            /**
12672             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
12673             *
12674             * <p>
12675             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12676             * </p>
12677             *
12678             * @param groupId the group ID
12679             * @param templateId the template ID
12680             * @param start the lower bound of the range of journal articles
12681             * @param end the upper bound of the range of journal articles (not inclusive)
12682             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12683             * @return the ordered range of matching journal articles that the user has permission to view
12684             * @throws SystemException if a system exception occurred
12685             */
12686            @Override
12687            public List<JournalArticle> filterFindByG_T(long groupId,
12688                    String templateId, int start, int end,
12689                    OrderByComparator orderByComparator) throws SystemException {
12690                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12691                            return findByG_T(groupId, templateId, start, end, orderByComparator);
12692                    }
12693    
12694                    StringBundler query = null;
12695    
12696                    if (orderByComparator != null) {
12697                            query = new StringBundler(4 +
12698                                            (orderByComparator.getOrderByFields().length * 3));
12699                    }
12700                    else {
12701                            query = new StringBundler(4);
12702                    }
12703    
12704                    if (getDB().isSupportsInlineDistinct()) {
12705                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12706                    }
12707                    else {
12708                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12709                    }
12710    
12711                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12712    
12713                    boolean bindTemplateId = false;
12714    
12715                    if (templateId == null) {
12716                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12717                    }
12718                    else if (templateId.equals(StringPool.BLANK)) {
12719                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12720                    }
12721                    else {
12722                            bindTemplateId = true;
12723    
12724                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12725                    }
12726    
12727                    if (!getDB().isSupportsInlineDistinct()) {
12728                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12729                    }
12730    
12731                    if (orderByComparator != null) {
12732                            if (getDB().isSupportsInlineDistinct()) {
12733                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12734                                            orderByComparator, true);
12735                            }
12736                            else {
12737                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12738                                            orderByComparator, true);
12739                            }
12740                    }
12741                    else {
12742                            if (getDB().isSupportsInlineDistinct()) {
12743                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12744                            }
12745                            else {
12746                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12747                            }
12748                    }
12749    
12750                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12751                                    JournalArticle.class.getName(),
12752                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12753    
12754                    Session session = null;
12755    
12756                    try {
12757                            session = openSession();
12758    
12759                            SQLQuery q = session.createSQLQuery(sql);
12760    
12761                            if (getDB().isSupportsInlineDistinct()) {
12762                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12763                            }
12764                            else {
12765                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12766                            }
12767    
12768                            QueryPos qPos = QueryPos.getInstance(q);
12769    
12770                            qPos.add(groupId);
12771    
12772                            if (bindTemplateId) {
12773                                    qPos.add(templateId);
12774                            }
12775    
12776                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12777                                    end);
12778                    }
12779                    catch (Exception e) {
12780                            throw processException(e);
12781                    }
12782                    finally {
12783                            closeSession(session);
12784                    }
12785            }
12786    
12787            /**
12788             * 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;.
12789             *
12790             * @param id the primary key of the current journal article
12791             * @param groupId the group ID
12792             * @param templateId the template ID
12793             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12794             * @return the previous, current, and next journal article
12795             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12796             * @throws SystemException if a system exception occurred
12797             */
12798            @Override
12799            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
12800                    String templateId, OrderByComparator orderByComparator)
12801                    throws NoSuchArticleException, SystemException {
12802                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12803                            return findByG_T_PrevAndNext(id, groupId, templateId,
12804                                    orderByComparator);
12805                    }
12806    
12807                    JournalArticle journalArticle = findByPrimaryKey(id);
12808    
12809                    Session session = null;
12810    
12811                    try {
12812                            session = openSession();
12813    
12814                            JournalArticle[] array = new JournalArticleImpl[3];
12815    
12816                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
12817                                            groupId, templateId, orderByComparator, true);
12818    
12819                            array[1] = journalArticle;
12820    
12821                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
12822                                            groupId, templateId, orderByComparator, false);
12823    
12824                            return array;
12825                    }
12826                    catch (Exception e) {
12827                            throw processException(e);
12828                    }
12829                    finally {
12830                            closeSession(session);
12831                    }
12832            }
12833    
12834            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
12835                    JournalArticle journalArticle, long groupId, String templateId,
12836                    OrderByComparator orderByComparator, boolean previous) {
12837                    StringBundler query = null;
12838    
12839                    if (orderByComparator != null) {
12840                            query = new StringBundler(6 +
12841                                            (orderByComparator.getOrderByFields().length * 6));
12842                    }
12843                    else {
12844                            query = new StringBundler(3);
12845                    }
12846    
12847                    if (getDB().isSupportsInlineDistinct()) {
12848                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12849                    }
12850                    else {
12851                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12852                    }
12853    
12854                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12855    
12856                    boolean bindTemplateId = false;
12857    
12858                    if (templateId == null) {
12859                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12860                    }
12861                    else if (templateId.equals(StringPool.BLANK)) {
12862                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12863                    }
12864                    else {
12865                            bindTemplateId = true;
12866    
12867                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12868                    }
12869    
12870                    if (!getDB().isSupportsInlineDistinct()) {
12871                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12872                    }
12873    
12874                    if (orderByComparator != null) {
12875                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12876    
12877                            if (orderByConditionFields.length > 0) {
12878                                    query.append(WHERE_AND);
12879                            }
12880    
12881                            for (int i = 0; i < orderByConditionFields.length; i++) {
12882                                    if (getDB().isSupportsInlineDistinct()) {
12883                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12884                                    }
12885                                    else {
12886                                            query.append(_ORDER_BY_ENTITY_TABLE);
12887                                    }
12888    
12889                                    query.append(orderByConditionFields[i]);
12890    
12891                                    if ((i + 1) < orderByConditionFields.length) {
12892                                            if (orderByComparator.isAscending() ^ previous) {
12893                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12894                                            }
12895                                            else {
12896                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12897                                            }
12898                                    }
12899                                    else {
12900                                            if (orderByComparator.isAscending() ^ previous) {
12901                                                    query.append(WHERE_GREATER_THAN);
12902                                            }
12903                                            else {
12904                                                    query.append(WHERE_LESSER_THAN);
12905                                            }
12906                                    }
12907                            }
12908    
12909                            query.append(ORDER_BY_CLAUSE);
12910    
12911                            String[] orderByFields = orderByComparator.getOrderByFields();
12912    
12913                            for (int i = 0; i < orderByFields.length; i++) {
12914                                    if (getDB().isSupportsInlineDistinct()) {
12915                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12916                                    }
12917                                    else {
12918                                            query.append(_ORDER_BY_ENTITY_TABLE);
12919                                    }
12920    
12921                                    query.append(orderByFields[i]);
12922    
12923                                    if ((i + 1) < orderByFields.length) {
12924                                            if (orderByComparator.isAscending() ^ previous) {
12925                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12926                                            }
12927                                            else {
12928                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12929                                            }
12930                                    }
12931                                    else {
12932                                            if (orderByComparator.isAscending() ^ previous) {
12933                                                    query.append(ORDER_BY_ASC);
12934                                            }
12935                                            else {
12936                                                    query.append(ORDER_BY_DESC);
12937                                            }
12938                                    }
12939                            }
12940                    }
12941                    else {
12942                            if (getDB().isSupportsInlineDistinct()) {
12943                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12944                            }
12945                            else {
12946                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12947                            }
12948                    }
12949    
12950                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12951                                    JournalArticle.class.getName(),
12952                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12953    
12954                    SQLQuery q = session.createSQLQuery(sql);
12955    
12956                    q.setFirstResult(0);
12957                    q.setMaxResults(2);
12958    
12959                    if (getDB().isSupportsInlineDistinct()) {
12960                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12961                    }
12962                    else {
12963                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12964                    }
12965    
12966                    QueryPos qPos = QueryPos.getInstance(q);
12967    
12968                    qPos.add(groupId);
12969    
12970                    if (bindTemplateId) {
12971                            qPos.add(templateId);
12972                    }
12973    
12974                    if (orderByComparator != null) {
12975                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12976    
12977                            for (Object value : values) {
12978                                    qPos.add(value);
12979                            }
12980                    }
12981    
12982                    List<JournalArticle> list = q.list();
12983    
12984                    if (list.size() == 2) {
12985                            return list.get(1);
12986                    }
12987                    else {
12988                            return null;
12989                    }
12990            }
12991    
12992            /**
12993             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
12994             *
12995             * @param groupId the group ID
12996             * @param templateId the template ID
12997             * @throws SystemException if a system exception occurred
12998             */
12999            @Override
13000            public void removeByG_T(long groupId, String templateId)
13001                    throws SystemException {
13002                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
13003                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13004                            remove(journalArticle);
13005                    }
13006            }
13007    
13008            /**
13009             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
13010             *
13011             * @param groupId the group ID
13012             * @param templateId the template ID
13013             * @return the number of matching journal articles
13014             * @throws SystemException if a system exception occurred
13015             */
13016            @Override
13017            public int countByG_T(long groupId, String templateId)
13018                    throws SystemException {
13019                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
13020    
13021                    Object[] finderArgs = new Object[] { groupId, templateId };
13022    
13023                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13024                                    this);
13025    
13026                    if (count == null) {
13027                            StringBundler query = new StringBundler(3);
13028    
13029                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13030    
13031                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13032    
13033                            boolean bindTemplateId = false;
13034    
13035                            if (templateId == null) {
13036                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13037                            }
13038                            else if (templateId.equals(StringPool.BLANK)) {
13039                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13040                            }
13041                            else {
13042                                    bindTemplateId = true;
13043    
13044                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13045                            }
13046    
13047                            String sql = query.toString();
13048    
13049                            Session session = null;
13050    
13051                            try {
13052                                    session = openSession();
13053    
13054                                    Query q = session.createQuery(sql);
13055    
13056                                    QueryPos qPos = QueryPos.getInstance(q);
13057    
13058                                    qPos.add(groupId);
13059    
13060                                    if (bindTemplateId) {
13061                                            qPos.add(templateId);
13062                                    }
13063    
13064                                    count = (Long)q.uniqueResult();
13065    
13066                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13067                            }
13068                            catch (Exception e) {
13069                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13070    
13071                                    throw processException(e);
13072                            }
13073                            finally {
13074                                    closeSession(session);
13075                            }
13076                    }
13077    
13078                    return count.intValue();
13079            }
13080    
13081            /**
13082             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
13083             *
13084             * @param groupId the group ID
13085             * @param templateId the template ID
13086             * @return the number of matching journal articles that the user has permission to view
13087             * @throws SystemException if a system exception occurred
13088             */
13089            @Override
13090            public int filterCountByG_T(long groupId, String templateId)
13091                    throws SystemException {
13092                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13093                            return countByG_T(groupId, templateId);
13094                    }
13095    
13096                    StringBundler query = new StringBundler(3);
13097    
13098                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13099    
13100                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13101    
13102                    boolean bindTemplateId = false;
13103    
13104                    if (templateId == null) {
13105                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13106                    }
13107                    else if (templateId.equals(StringPool.BLANK)) {
13108                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13109                    }
13110                    else {
13111                            bindTemplateId = true;
13112    
13113                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13114                    }
13115    
13116                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13117                                    JournalArticle.class.getName(),
13118                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13119    
13120                    Session session = null;
13121    
13122                    try {
13123                            session = openSession();
13124    
13125                            SQLQuery q = session.createSQLQuery(sql);
13126    
13127                            q.addScalar(COUNT_COLUMN_NAME,
13128                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13129    
13130                            QueryPos qPos = QueryPos.getInstance(q);
13131    
13132                            qPos.add(groupId);
13133    
13134                            if (bindTemplateId) {
13135                                    qPos.add(templateId);
13136                            }
13137    
13138                            Long count = (Long)q.uniqueResult();
13139    
13140                            return count.intValue();
13141                    }
13142                    catch (Exception e) {
13143                            throw processException(e);
13144                    }
13145                    finally {
13146                            closeSession(session);
13147                    }
13148            }
13149    
13150            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
13151            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
13152            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
13153            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
13154            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13155                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13156                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13157                            "findByG_L",
13158                            new String[] {
13159                                    Long.class.getName(), String.class.getName(),
13160                                    
13161                            Integer.class.getName(), Integer.class.getName(),
13162                                    OrderByComparator.class.getName()
13163                            });
13164            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13165                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13166                            JournalArticleImpl.class,
13167                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
13168                            new String[] { Long.class.getName(), String.class.getName() },
13169                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13170                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
13171                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13172                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13173            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13174                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13175                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
13176                            new String[] { Long.class.getName(), String.class.getName() });
13177    
13178            /**
13179             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13180             *
13181             * @param groupId the group ID
13182             * @param layoutUuid the layout uuid
13183             * @return the matching journal articles
13184             * @throws SystemException if a system exception occurred
13185             */
13186            @Override
13187            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
13188                    throws SystemException {
13189                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13190                            QueryUtil.ALL_POS, null);
13191            }
13192    
13193            /**
13194             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13195             *
13196             * <p>
13197             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13198             * </p>
13199             *
13200             * @param groupId the group ID
13201             * @param layoutUuid the layout uuid
13202             * @param start the lower bound of the range of journal articles
13203             * @param end the upper bound of the range of journal articles (not inclusive)
13204             * @return the range of matching journal articles
13205             * @throws SystemException if a system exception occurred
13206             */
13207            @Override
13208            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13209                    int start, int end) throws SystemException {
13210                    return findByG_L(groupId, layoutUuid, start, end, null);
13211            }
13212    
13213            /**
13214             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13215             *
13216             * <p>
13217             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13218             * </p>
13219             *
13220             * @param groupId the group ID
13221             * @param layoutUuid the layout uuid
13222             * @param start the lower bound of the range of journal articles
13223             * @param end the upper bound of the range of journal articles (not inclusive)
13224             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13225             * @return the ordered range of matching journal articles
13226             * @throws SystemException if a system exception occurred
13227             */
13228            @Override
13229            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13230                    int start, int end, OrderByComparator orderByComparator)
13231                    throws SystemException {
13232                    boolean pagination = true;
13233                    FinderPath finderPath = null;
13234                    Object[] finderArgs = null;
13235    
13236                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13237                                    (orderByComparator == null)) {
13238                            pagination = false;
13239                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
13240                            finderArgs = new Object[] { groupId, layoutUuid };
13241                    }
13242                    else {
13243                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
13244                            finderArgs = new Object[] {
13245                                            groupId, layoutUuid,
13246                                            
13247                                            start, end, orderByComparator
13248                                    };
13249                    }
13250    
13251                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13252                                    finderArgs, this);
13253    
13254                    if ((list != null) && !list.isEmpty()) {
13255                            for (JournalArticle journalArticle : list) {
13256                                    if ((groupId != journalArticle.getGroupId()) ||
13257                                                    !Validator.equals(layoutUuid,
13258                                                            journalArticle.getLayoutUuid())) {
13259                                            list = null;
13260    
13261                                            break;
13262                                    }
13263                            }
13264                    }
13265    
13266                    if (list == null) {
13267                            StringBundler query = null;
13268    
13269                            if (orderByComparator != null) {
13270                                    query = new StringBundler(4 +
13271                                                    (orderByComparator.getOrderByFields().length * 3));
13272                            }
13273                            else {
13274                                    query = new StringBundler(4);
13275                            }
13276    
13277                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13278    
13279                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13280    
13281                            boolean bindLayoutUuid = false;
13282    
13283                            if (layoutUuid == null) {
13284                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13285                            }
13286                            else if (layoutUuid.equals(StringPool.BLANK)) {
13287                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13288                            }
13289                            else {
13290                                    bindLayoutUuid = true;
13291    
13292                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13293                            }
13294    
13295                            if (orderByComparator != null) {
13296                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13297                                            orderByComparator);
13298                            }
13299                            else
13300                             if (pagination) {
13301                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13302                            }
13303    
13304                            String sql = query.toString();
13305    
13306                            Session session = null;
13307    
13308                            try {
13309                                    session = openSession();
13310    
13311                                    Query q = session.createQuery(sql);
13312    
13313                                    QueryPos qPos = QueryPos.getInstance(q);
13314    
13315                                    qPos.add(groupId);
13316    
13317                                    if (bindLayoutUuid) {
13318                                            qPos.add(layoutUuid);
13319                                    }
13320    
13321                                    if (!pagination) {
13322                                            list = (List<JournalArticle>)QueryUtil.list(q,
13323                                                            getDialect(), start, end, false);
13324    
13325                                            Collections.sort(list);
13326    
13327                                            list = new UnmodifiableList<JournalArticle>(list);
13328                                    }
13329                                    else {
13330                                            list = (List<JournalArticle>)QueryUtil.list(q,
13331                                                            getDialect(), start, end);
13332                                    }
13333    
13334                                    cacheResult(list);
13335    
13336                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13337                            }
13338                            catch (Exception e) {
13339                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13340    
13341                                    throw processException(e);
13342                            }
13343                            finally {
13344                                    closeSession(session);
13345                            }
13346                    }
13347    
13348                    return list;
13349            }
13350    
13351            /**
13352             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13353             *
13354             * @param groupId the group ID
13355             * @param layoutUuid the layout uuid
13356             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13357             * @return the first matching journal article
13358             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13359             * @throws SystemException if a system exception occurred
13360             */
13361            @Override
13362            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
13363                    OrderByComparator orderByComparator)
13364                    throws NoSuchArticleException, SystemException {
13365                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
13366                                    orderByComparator);
13367    
13368                    if (journalArticle != null) {
13369                            return journalArticle;
13370                    }
13371    
13372                    StringBundler msg = new StringBundler(6);
13373    
13374                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13375    
13376                    msg.append("groupId=");
13377                    msg.append(groupId);
13378    
13379                    msg.append(", layoutUuid=");
13380                    msg.append(layoutUuid);
13381    
13382                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13383    
13384                    throw new NoSuchArticleException(msg.toString());
13385            }
13386    
13387            /**
13388             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13389             *
13390             * @param groupId the group ID
13391             * @param layoutUuid the layout uuid
13392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13393             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13394             * @throws SystemException if a system exception occurred
13395             */
13396            @Override
13397            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
13398                    OrderByComparator orderByComparator) throws SystemException {
13399                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
13400                                    orderByComparator);
13401    
13402                    if (!list.isEmpty()) {
13403                            return list.get(0);
13404                    }
13405    
13406                    return null;
13407            }
13408    
13409            /**
13410             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13411             *
13412             * @param groupId the group ID
13413             * @param layoutUuid the layout uuid
13414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13415             * @return the last matching journal article
13416             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13417             * @throws SystemException if a system exception occurred
13418             */
13419            @Override
13420            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
13421                    OrderByComparator orderByComparator)
13422                    throws NoSuchArticleException, SystemException {
13423                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
13424                                    orderByComparator);
13425    
13426                    if (journalArticle != null) {
13427                            return journalArticle;
13428                    }
13429    
13430                    StringBundler msg = new StringBundler(6);
13431    
13432                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13433    
13434                    msg.append("groupId=");
13435                    msg.append(groupId);
13436    
13437                    msg.append(", layoutUuid=");
13438                    msg.append(layoutUuid);
13439    
13440                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13441    
13442                    throw new NoSuchArticleException(msg.toString());
13443            }
13444    
13445            /**
13446             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13447             *
13448             * @param groupId the group ID
13449             * @param layoutUuid the layout uuid
13450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13451             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13452             * @throws SystemException if a system exception occurred
13453             */
13454            @Override
13455            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
13456                    OrderByComparator orderByComparator) throws SystemException {
13457                    int count = countByG_L(groupId, layoutUuid);
13458    
13459                    if (count == 0) {
13460                            return null;
13461                    }
13462    
13463                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
13464                                    count, orderByComparator);
13465    
13466                    if (!list.isEmpty()) {
13467                            return list.get(0);
13468                    }
13469    
13470                    return null;
13471            }
13472    
13473            /**
13474             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13475             *
13476             * @param id the primary key of the current journal article
13477             * @param groupId the group ID
13478             * @param layoutUuid the layout uuid
13479             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13480             * @return the previous, current, and next journal article
13481             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13482             * @throws SystemException if a system exception occurred
13483             */
13484            @Override
13485            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
13486                    String layoutUuid, OrderByComparator orderByComparator)
13487                    throws NoSuchArticleException, SystemException {
13488                    JournalArticle journalArticle = findByPrimaryKey(id);
13489    
13490                    Session session = null;
13491    
13492                    try {
13493                            session = openSession();
13494    
13495                            JournalArticle[] array = new JournalArticleImpl[3];
13496    
13497                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13498                                            layoutUuid, orderByComparator, true);
13499    
13500                            array[1] = journalArticle;
13501    
13502                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13503                                            layoutUuid, orderByComparator, false);
13504    
13505                            return array;
13506                    }
13507                    catch (Exception e) {
13508                            throw processException(e);
13509                    }
13510                    finally {
13511                            closeSession(session);
13512                    }
13513            }
13514    
13515            protected JournalArticle getByG_L_PrevAndNext(Session session,
13516                    JournalArticle journalArticle, long groupId, String layoutUuid,
13517                    OrderByComparator orderByComparator, boolean previous) {
13518                    StringBundler query = null;
13519    
13520                    if (orderByComparator != null) {
13521                            query = new StringBundler(6 +
13522                                            (orderByComparator.getOrderByFields().length * 6));
13523                    }
13524                    else {
13525                            query = new StringBundler(3);
13526                    }
13527    
13528                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13529    
13530                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13531    
13532                    boolean bindLayoutUuid = false;
13533    
13534                    if (layoutUuid == null) {
13535                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13536                    }
13537                    else if (layoutUuid.equals(StringPool.BLANK)) {
13538                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13539                    }
13540                    else {
13541                            bindLayoutUuid = true;
13542    
13543                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13544                    }
13545    
13546                    if (orderByComparator != null) {
13547                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13548    
13549                            if (orderByConditionFields.length > 0) {
13550                                    query.append(WHERE_AND);
13551                            }
13552    
13553                            for (int i = 0; i < orderByConditionFields.length; i++) {
13554                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13555                                    query.append(orderByConditionFields[i]);
13556    
13557                                    if ((i + 1) < orderByConditionFields.length) {
13558                                            if (orderByComparator.isAscending() ^ previous) {
13559                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13560                                            }
13561                                            else {
13562                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13563                                            }
13564                                    }
13565                                    else {
13566                                            if (orderByComparator.isAscending() ^ previous) {
13567                                                    query.append(WHERE_GREATER_THAN);
13568                                            }
13569                                            else {
13570                                                    query.append(WHERE_LESSER_THAN);
13571                                            }
13572                                    }
13573                            }
13574    
13575                            query.append(ORDER_BY_CLAUSE);
13576    
13577                            String[] orderByFields = orderByComparator.getOrderByFields();
13578    
13579                            for (int i = 0; i < orderByFields.length; i++) {
13580                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13581                                    query.append(orderByFields[i]);
13582    
13583                                    if ((i + 1) < orderByFields.length) {
13584                                            if (orderByComparator.isAscending() ^ previous) {
13585                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13586                                            }
13587                                            else {
13588                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13589                                            }
13590                                    }
13591                                    else {
13592                                            if (orderByComparator.isAscending() ^ previous) {
13593                                                    query.append(ORDER_BY_ASC);
13594                                            }
13595                                            else {
13596                                                    query.append(ORDER_BY_DESC);
13597                                            }
13598                                    }
13599                            }
13600                    }
13601                    else {
13602                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13603                    }
13604    
13605                    String sql = query.toString();
13606    
13607                    Query q = session.createQuery(sql);
13608    
13609                    q.setFirstResult(0);
13610                    q.setMaxResults(2);
13611    
13612                    QueryPos qPos = QueryPos.getInstance(q);
13613    
13614                    qPos.add(groupId);
13615    
13616                    if (bindLayoutUuid) {
13617                            qPos.add(layoutUuid);
13618                    }
13619    
13620                    if (orderByComparator != null) {
13621                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13622    
13623                            for (Object value : values) {
13624                                    qPos.add(value);
13625                            }
13626                    }
13627    
13628                    List<JournalArticle> list = q.list();
13629    
13630                    if (list.size() == 2) {
13631                            return list.get(1);
13632                    }
13633                    else {
13634                            return null;
13635                    }
13636            }
13637    
13638            /**
13639             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13640             *
13641             * @param groupId the group ID
13642             * @param layoutUuid the layout uuid
13643             * @return the matching journal articles that the user has permission to view
13644             * @throws SystemException if a system exception occurred
13645             */
13646            @Override
13647            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
13648                    throws SystemException {
13649                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13650                            QueryUtil.ALL_POS, null);
13651            }
13652    
13653            /**
13654             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13655             *
13656             * <p>
13657             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13658             * </p>
13659             *
13660             * @param groupId the group ID
13661             * @param layoutUuid the layout uuid
13662             * @param start the lower bound of the range of journal articles
13663             * @param end the upper bound of the range of journal articles (not inclusive)
13664             * @return the range of matching journal articles that the user has permission to view
13665             * @throws SystemException if a system exception occurred
13666             */
13667            @Override
13668            public List<JournalArticle> filterFindByG_L(long groupId,
13669                    String layoutUuid, int start, int end) throws SystemException {
13670                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
13671            }
13672    
13673            /**
13674             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
13675             *
13676             * <p>
13677             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13678             * </p>
13679             *
13680             * @param groupId the group ID
13681             * @param layoutUuid the layout uuid
13682             * @param start the lower bound of the range of journal articles
13683             * @param end the upper bound of the range of journal articles (not inclusive)
13684             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13685             * @return the ordered range of matching journal articles that the user has permission to view
13686             * @throws SystemException if a system exception occurred
13687             */
13688            @Override
13689            public List<JournalArticle> filterFindByG_L(long groupId,
13690                    String layoutUuid, int start, int end,
13691                    OrderByComparator orderByComparator) throws SystemException {
13692                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13693                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
13694                    }
13695    
13696                    StringBundler query = null;
13697    
13698                    if (orderByComparator != null) {
13699                            query = new StringBundler(4 +
13700                                            (orderByComparator.getOrderByFields().length * 3));
13701                    }
13702                    else {
13703                            query = new StringBundler(4);
13704                    }
13705    
13706                    if (getDB().isSupportsInlineDistinct()) {
13707                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13708                    }
13709                    else {
13710                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13711                    }
13712    
13713                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13714    
13715                    boolean bindLayoutUuid = false;
13716    
13717                    if (layoutUuid == null) {
13718                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13719                    }
13720                    else if (layoutUuid.equals(StringPool.BLANK)) {
13721                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13722                    }
13723                    else {
13724                            bindLayoutUuid = true;
13725    
13726                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13727                    }
13728    
13729                    if (!getDB().isSupportsInlineDistinct()) {
13730                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13731                    }
13732    
13733                    if (orderByComparator != null) {
13734                            if (getDB().isSupportsInlineDistinct()) {
13735                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13736                                            orderByComparator, true);
13737                            }
13738                            else {
13739                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13740                                            orderByComparator, true);
13741                            }
13742                    }
13743                    else {
13744                            if (getDB().isSupportsInlineDistinct()) {
13745                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13746                            }
13747                            else {
13748                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13749                            }
13750                    }
13751    
13752                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13753                                    JournalArticle.class.getName(),
13754                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13755    
13756                    Session session = null;
13757    
13758                    try {
13759                            session = openSession();
13760    
13761                            SQLQuery q = session.createSQLQuery(sql);
13762    
13763                            if (getDB().isSupportsInlineDistinct()) {
13764                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13765                            }
13766                            else {
13767                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13768                            }
13769    
13770                            QueryPos qPos = QueryPos.getInstance(q);
13771    
13772                            qPos.add(groupId);
13773    
13774                            if (bindLayoutUuid) {
13775                                    qPos.add(layoutUuid);
13776                            }
13777    
13778                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13779                                    end);
13780                    }
13781                    catch (Exception e) {
13782                            throw processException(e);
13783                    }
13784                    finally {
13785                            closeSession(session);
13786                    }
13787            }
13788    
13789            /**
13790             * 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;.
13791             *
13792             * @param id the primary key of the current journal article
13793             * @param groupId the group ID
13794             * @param layoutUuid the layout uuid
13795             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13796             * @return the previous, current, and next journal article
13797             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13798             * @throws SystemException if a system exception occurred
13799             */
13800            @Override
13801            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
13802                    String layoutUuid, OrderByComparator orderByComparator)
13803                    throws NoSuchArticleException, SystemException {
13804                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13805                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
13806                                    orderByComparator);
13807                    }
13808    
13809                    JournalArticle journalArticle = findByPrimaryKey(id);
13810    
13811                    Session session = null;
13812    
13813                    try {
13814                            session = openSession();
13815    
13816                            JournalArticle[] array = new JournalArticleImpl[3];
13817    
13818                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
13819                                            groupId, layoutUuid, orderByComparator, true);
13820    
13821                            array[1] = journalArticle;
13822    
13823                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
13824                                            groupId, layoutUuid, orderByComparator, false);
13825    
13826                            return array;
13827                    }
13828                    catch (Exception e) {
13829                            throw processException(e);
13830                    }
13831                    finally {
13832                            closeSession(session);
13833                    }
13834            }
13835    
13836            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
13837                    JournalArticle journalArticle, long groupId, String layoutUuid,
13838                    OrderByComparator orderByComparator, boolean previous) {
13839                    StringBundler query = null;
13840    
13841                    if (orderByComparator != null) {
13842                            query = new StringBundler(6 +
13843                                            (orderByComparator.getOrderByFields().length * 6));
13844                    }
13845                    else {
13846                            query = new StringBundler(3);
13847                    }
13848    
13849                    if (getDB().isSupportsInlineDistinct()) {
13850                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13851                    }
13852                    else {
13853                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13854                    }
13855    
13856                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13857    
13858                    boolean bindLayoutUuid = false;
13859    
13860                    if (layoutUuid == null) {
13861                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13862                    }
13863                    else if (layoutUuid.equals(StringPool.BLANK)) {
13864                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13865                    }
13866                    else {
13867                            bindLayoutUuid = true;
13868    
13869                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13870                    }
13871    
13872                    if (!getDB().isSupportsInlineDistinct()) {
13873                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13874                    }
13875    
13876                    if (orderByComparator != null) {
13877                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13878    
13879                            if (orderByConditionFields.length > 0) {
13880                                    query.append(WHERE_AND);
13881                            }
13882    
13883                            for (int i = 0; i < orderByConditionFields.length; i++) {
13884                                    if (getDB().isSupportsInlineDistinct()) {
13885                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13886                                    }
13887                                    else {
13888                                            query.append(_ORDER_BY_ENTITY_TABLE);
13889                                    }
13890    
13891                                    query.append(orderByConditionFields[i]);
13892    
13893                                    if ((i + 1) < orderByConditionFields.length) {
13894                                            if (orderByComparator.isAscending() ^ previous) {
13895                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13896                                            }
13897                                            else {
13898                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13899                                            }
13900                                    }
13901                                    else {
13902                                            if (orderByComparator.isAscending() ^ previous) {
13903                                                    query.append(WHERE_GREATER_THAN);
13904                                            }
13905                                            else {
13906                                                    query.append(WHERE_LESSER_THAN);
13907                                            }
13908                                    }
13909                            }
13910    
13911                            query.append(ORDER_BY_CLAUSE);
13912    
13913                            String[] orderByFields = orderByComparator.getOrderByFields();
13914    
13915                            for (int i = 0; i < orderByFields.length; i++) {
13916                                    if (getDB().isSupportsInlineDistinct()) {
13917                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13918                                    }
13919                                    else {
13920                                            query.append(_ORDER_BY_ENTITY_TABLE);
13921                                    }
13922    
13923                                    query.append(orderByFields[i]);
13924    
13925                                    if ((i + 1) < orderByFields.length) {
13926                                            if (orderByComparator.isAscending() ^ previous) {
13927                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13928                                            }
13929                                            else {
13930                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13931                                            }
13932                                    }
13933                                    else {
13934                                            if (orderByComparator.isAscending() ^ previous) {
13935                                                    query.append(ORDER_BY_ASC);
13936                                            }
13937                                            else {
13938                                                    query.append(ORDER_BY_DESC);
13939                                            }
13940                                    }
13941                            }
13942                    }
13943                    else {
13944                            if (getDB().isSupportsInlineDistinct()) {
13945                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13946                            }
13947                            else {
13948                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13949                            }
13950                    }
13951    
13952                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13953                                    JournalArticle.class.getName(),
13954                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13955    
13956                    SQLQuery q = session.createSQLQuery(sql);
13957    
13958                    q.setFirstResult(0);
13959                    q.setMaxResults(2);
13960    
13961                    if (getDB().isSupportsInlineDistinct()) {
13962                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13963                    }
13964                    else {
13965                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13966                    }
13967    
13968                    QueryPos qPos = QueryPos.getInstance(q);
13969    
13970                    qPos.add(groupId);
13971    
13972                    if (bindLayoutUuid) {
13973                            qPos.add(layoutUuid);
13974                    }
13975    
13976                    if (orderByComparator != null) {
13977                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13978    
13979                            for (Object value : values) {
13980                                    qPos.add(value);
13981                            }
13982                    }
13983    
13984                    List<JournalArticle> list = q.list();
13985    
13986                    if (list.size() == 2) {
13987                            return list.get(1);
13988                    }
13989                    else {
13990                            return null;
13991                    }
13992            }
13993    
13994            /**
13995             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
13996             *
13997             * @param groupId the group ID
13998             * @param layoutUuid the layout uuid
13999             * @throws SystemException if a system exception occurred
14000             */
14001            @Override
14002            public void removeByG_L(long groupId, String layoutUuid)
14003                    throws SystemException {
14004                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
14005                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14006                            remove(journalArticle);
14007                    }
14008            }
14009    
14010            /**
14011             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
14012             *
14013             * @param groupId the group ID
14014             * @param layoutUuid the layout uuid
14015             * @return the number of matching journal articles
14016             * @throws SystemException if a system exception occurred
14017             */
14018            @Override
14019            public int countByG_L(long groupId, String layoutUuid)
14020                    throws SystemException {
14021                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
14022    
14023                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
14024    
14025                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14026                                    this);
14027    
14028                    if (count == null) {
14029                            StringBundler query = new StringBundler(3);
14030    
14031                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14032    
14033                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14034    
14035                            boolean bindLayoutUuid = false;
14036    
14037                            if (layoutUuid == null) {
14038                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14039                            }
14040                            else if (layoutUuid.equals(StringPool.BLANK)) {
14041                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14042                            }
14043                            else {
14044                                    bindLayoutUuid = true;
14045    
14046                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14047                            }
14048    
14049                            String sql = query.toString();
14050    
14051                            Session session = null;
14052    
14053                            try {
14054                                    session = openSession();
14055    
14056                                    Query q = session.createQuery(sql);
14057    
14058                                    QueryPos qPos = QueryPos.getInstance(q);
14059    
14060                                    qPos.add(groupId);
14061    
14062                                    if (bindLayoutUuid) {
14063                                            qPos.add(layoutUuid);
14064                                    }
14065    
14066                                    count = (Long)q.uniqueResult();
14067    
14068                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14069                            }
14070                            catch (Exception e) {
14071                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14072    
14073                                    throw processException(e);
14074                            }
14075                            finally {
14076                                    closeSession(session);
14077                            }
14078                    }
14079    
14080                    return count.intValue();
14081            }
14082    
14083            /**
14084             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
14085             *
14086             * @param groupId the group ID
14087             * @param layoutUuid the layout uuid
14088             * @return the number of matching journal articles that the user has permission to view
14089             * @throws SystemException if a system exception occurred
14090             */
14091            @Override
14092            public int filterCountByG_L(long groupId, String layoutUuid)
14093                    throws SystemException {
14094                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14095                            return countByG_L(groupId, layoutUuid);
14096                    }
14097    
14098                    StringBundler query = new StringBundler(3);
14099    
14100                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14101    
14102                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14103    
14104                    boolean bindLayoutUuid = false;
14105    
14106                    if (layoutUuid == null) {
14107                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14108                    }
14109                    else if (layoutUuid.equals(StringPool.BLANK)) {
14110                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14111                    }
14112                    else {
14113                            bindLayoutUuid = true;
14114    
14115                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14116                    }
14117    
14118                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14119                                    JournalArticle.class.getName(),
14120                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14121    
14122                    Session session = null;
14123    
14124                    try {
14125                            session = openSession();
14126    
14127                            SQLQuery q = session.createSQLQuery(sql);
14128    
14129                            q.addScalar(COUNT_COLUMN_NAME,
14130                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14131    
14132                            QueryPos qPos = QueryPos.getInstance(q);
14133    
14134                            qPos.add(groupId);
14135    
14136                            if (bindLayoutUuid) {
14137                                    qPos.add(layoutUuid);
14138                            }
14139    
14140                            Long count = (Long)q.uniqueResult();
14141    
14142                            return count.intValue();
14143                    }
14144                    catch (Exception e) {
14145                            throw processException(e);
14146                    }
14147                    finally {
14148                            closeSession(session);
14149                    }
14150            }
14151    
14152            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
14153            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
14154            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
14155            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
14156            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14157                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14158                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14159                            "findByG_ST",
14160                            new String[] {
14161                                    Long.class.getName(), Integer.class.getName(),
14162                                    
14163                            Integer.class.getName(), Integer.class.getName(),
14164                                    OrderByComparator.class.getName()
14165                            });
14166            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14167                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14168                            JournalArticleImpl.class,
14169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
14170                            new String[] { Long.class.getName(), Integer.class.getName() },
14171                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
14172                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14173                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14174                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14175            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14176                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14177                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
14178                            new String[] { Long.class.getName(), Integer.class.getName() });
14179    
14180            /**
14181             * Returns all the journal articles where groupId = &#63; and status = &#63;.
14182             *
14183             * @param groupId the group ID
14184             * @param status the status
14185             * @return the matching journal articles
14186             * @throws SystemException if a system exception occurred
14187             */
14188            @Override
14189            public List<JournalArticle> findByG_ST(long groupId, int status)
14190                    throws SystemException {
14191                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
14192                            QueryUtil.ALL_POS, null);
14193            }
14194    
14195            /**
14196             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
14197             *
14198             * <p>
14199             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14200             * </p>
14201             *
14202             * @param groupId the group ID
14203             * @param status the status
14204             * @param start the lower bound of the range of journal articles
14205             * @param end the upper bound of the range of journal articles (not inclusive)
14206             * @return the range of matching journal articles
14207             * @throws SystemException if a system exception occurred
14208             */
14209            @Override
14210            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14211                    int end) throws SystemException {
14212                    return findByG_ST(groupId, status, start, end, null);
14213            }
14214    
14215            /**
14216             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
14217             *
14218             * <p>
14219             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14220             * </p>
14221             *
14222             * @param groupId the group ID
14223             * @param status the status
14224             * @param start the lower bound of the range of journal articles
14225             * @param end the upper bound of the range of journal articles (not inclusive)
14226             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14227             * @return the ordered range of matching journal articles
14228             * @throws SystemException if a system exception occurred
14229             */
14230            @Override
14231            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14232                    int end, OrderByComparator orderByComparator) throws SystemException {
14233                    boolean pagination = true;
14234                    FinderPath finderPath = null;
14235                    Object[] finderArgs = null;
14236    
14237                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14238                                    (orderByComparator == null)) {
14239                            pagination = false;
14240                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
14241                            finderArgs = new Object[] { groupId, status };
14242                    }
14243                    else {
14244                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
14245                            finderArgs = new Object[] {
14246                                            groupId, status,
14247                                            
14248                                            start, end, orderByComparator
14249                                    };
14250                    }
14251    
14252                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14253                                    finderArgs, this);
14254    
14255                    if ((list != null) && !list.isEmpty()) {
14256                            for (JournalArticle journalArticle : list) {
14257                                    if ((groupId != journalArticle.getGroupId()) ||
14258                                                    (status != journalArticle.getStatus())) {
14259                                            list = null;
14260    
14261                                            break;
14262                                    }
14263                            }
14264                    }
14265    
14266                    if (list == null) {
14267                            StringBundler query = null;
14268    
14269                            if (orderByComparator != null) {
14270                                    query = new StringBundler(4 +
14271                                                    (orderByComparator.getOrderByFields().length * 3));
14272                            }
14273                            else {
14274                                    query = new StringBundler(4);
14275                            }
14276    
14277                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14278    
14279                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14280    
14281                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14282    
14283                            if (orderByComparator != null) {
14284                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14285                                            orderByComparator);
14286                            }
14287                            else
14288                             if (pagination) {
14289                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14290                            }
14291    
14292                            String sql = query.toString();
14293    
14294                            Session session = null;
14295    
14296                            try {
14297                                    session = openSession();
14298    
14299                                    Query q = session.createQuery(sql);
14300    
14301                                    QueryPos qPos = QueryPos.getInstance(q);
14302    
14303                                    qPos.add(groupId);
14304    
14305                                    qPos.add(status);
14306    
14307                                    if (!pagination) {
14308                                            list = (List<JournalArticle>)QueryUtil.list(q,
14309                                                            getDialect(), start, end, false);
14310    
14311                                            Collections.sort(list);
14312    
14313                                            list = new UnmodifiableList<JournalArticle>(list);
14314                                    }
14315                                    else {
14316                                            list = (List<JournalArticle>)QueryUtil.list(q,
14317                                                            getDialect(), start, end);
14318                                    }
14319    
14320                                    cacheResult(list);
14321    
14322                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14323                            }
14324                            catch (Exception e) {
14325                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14326    
14327                                    throw processException(e);
14328                            }
14329                            finally {
14330                                    closeSession(session);
14331                            }
14332                    }
14333    
14334                    return list;
14335            }
14336    
14337            /**
14338             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14339             *
14340             * @param groupId the group ID
14341             * @param status the status
14342             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14343             * @return the first matching journal article
14344             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14345             * @throws SystemException if a system exception occurred
14346             */
14347            @Override
14348            public JournalArticle findByG_ST_First(long groupId, int status,
14349                    OrderByComparator orderByComparator)
14350                    throws NoSuchArticleException, SystemException {
14351                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
14352                                    orderByComparator);
14353    
14354                    if (journalArticle != null) {
14355                            return journalArticle;
14356                    }
14357    
14358                    StringBundler msg = new StringBundler(6);
14359    
14360                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14361    
14362                    msg.append("groupId=");
14363                    msg.append(groupId);
14364    
14365                    msg.append(", status=");
14366                    msg.append(status);
14367    
14368                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14369    
14370                    throw new NoSuchArticleException(msg.toString());
14371            }
14372    
14373            /**
14374             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14375             *
14376             * @param groupId the group ID
14377             * @param status the status
14378             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14379             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14380             * @throws SystemException if a system exception occurred
14381             */
14382            @Override
14383            public JournalArticle fetchByG_ST_First(long groupId, int status,
14384                    OrderByComparator orderByComparator) throws SystemException {
14385                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
14386                                    orderByComparator);
14387    
14388                    if (!list.isEmpty()) {
14389                            return list.get(0);
14390                    }
14391    
14392                    return null;
14393            }
14394    
14395            /**
14396             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14397             *
14398             * @param groupId the group ID
14399             * @param status the status
14400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14401             * @return the last matching journal article
14402             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14403             * @throws SystemException if a system exception occurred
14404             */
14405            @Override
14406            public JournalArticle findByG_ST_Last(long groupId, int status,
14407                    OrderByComparator orderByComparator)
14408                    throws NoSuchArticleException, SystemException {
14409                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
14410                                    orderByComparator);
14411    
14412                    if (journalArticle != null) {
14413                            return journalArticle;
14414                    }
14415    
14416                    StringBundler msg = new StringBundler(6);
14417    
14418                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14419    
14420                    msg.append("groupId=");
14421                    msg.append(groupId);
14422    
14423                    msg.append(", status=");
14424                    msg.append(status);
14425    
14426                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14427    
14428                    throw new NoSuchArticleException(msg.toString());
14429            }
14430    
14431            /**
14432             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14433             *
14434             * @param groupId the group ID
14435             * @param status the status
14436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14437             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14438             * @throws SystemException if a system exception occurred
14439             */
14440            @Override
14441            public JournalArticle fetchByG_ST_Last(long groupId, int status,
14442                    OrderByComparator orderByComparator) throws SystemException {
14443                    int count = countByG_ST(groupId, status);
14444    
14445                    if (count == 0) {
14446                            return null;
14447                    }
14448    
14449                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
14450                                    count, orderByComparator);
14451    
14452                    if (!list.isEmpty()) {
14453                            return list.get(0);
14454                    }
14455    
14456                    return null;
14457            }
14458    
14459            /**
14460             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
14461             *
14462             * @param id the primary key of the current journal article
14463             * @param groupId the group ID
14464             * @param status the status
14465             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14466             * @return the previous, current, and next journal article
14467             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14468             * @throws SystemException if a system exception occurred
14469             */
14470            @Override
14471            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
14472                    int status, OrderByComparator orderByComparator)
14473                    throws NoSuchArticleException, SystemException {
14474                    JournalArticle journalArticle = findByPrimaryKey(id);
14475    
14476                    Session session = null;
14477    
14478                    try {
14479                            session = openSession();
14480    
14481                            JournalArticle[] array = new JournalArticleImpl[3];
14482    
14483                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14484                                            status, orderByComparator, true);
14485    
14486                            array[1] = journalArticle;
14487    
14488                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14489                                            status, orderByComparator, false);
14490    
14491                            return array;
14492                    }
14493                    catch (Exception e) {
14494                            throw processException(e);
14495                    }
14496                    finally {
14497                            closeSession(session);
14498                    }
14499            }
14500    
14501            protected JournalArticle getByG_ST_PrevAndNext(Session session,
14502                    JournalArticle journalArticle, long groupId, int status,
14503                    OrderByComparator orderByComparator, boolean previous) {
14504                    StringBundler query = null;
14505    
14506                    if (orderByComparator != null) {
14507                            query = new StringBundler(6 +
14508                                            (orderByComparator.getOrderByFields().length * 6));
14509                    }
14510                    else {
14511                            query = new StringBundler(3);
14512                    }
14513    
14514                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14515    
14516                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14517    
14518                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14519    
14520                    if (orderByComparator != null) {
14521                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14522    
14523                            if (orderByConditionFields.length > 0) {
14524                                    query.append(WHERE_AND);
14525                            }
14526    
14527                            for (int i = 0; i < orderByConditionFields.length; i++) {
14528                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14529                                    query.append(orderByConditionFields[i]);
14530    
14531                                    if ((i + 1) < orderByConditionFields.length) {
14532                                            if (orderByComparator.isAscending() ^ previous) {
14533                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14534                                            }
14535                                            else {
14536                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14537                                            }
14538                                    }
14539                                    else {
14540                                            if (orderByComparator.isAscending() ^ previous) {
14541                                                    query.append(WHERE_GREATER_THAN);
14542                                            }
14543                                            else {
14544                                                    query.append(WHERE_LESSER_THAN);
14545                                            }
14546                                    }
14547                            }
14548    
14549                            query.append(ORDER_BY_CLAUSE);
14550    
14551                            String[] orderByFields = orderByComparator.getOrderByFields();
14552    
14553                            for (int i = 0; i < orderByFields.length; i++) {
14554                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14555                                    query.append(orderByFields[i]);
14556    
14557                                    if ((i + 1) < orderByFields.length) {
14558                                            if (orderByComparator.isAscending() ^ previous) {
14559                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14560                                            }
14561                                            else {
14562                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14563                                            }
14564                                    }
14565                                    else {
14566                                            if (orderByComparator.isAscending() ^ previous) {
14567                                                    query.append(ORDER_BY_ASC);
14568                                            }
14569                                            else {
14570                                                    query.append(ORDER_BY_DESC);
14571                                            }
14572                                    }
14573                            }
14574                    }
14575                    else {
14576                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14577                    }
14578    
14579                    String sql = query.toString();
14580    
14581                    Query q = session.createQuery(sql);
14582    
14583                    q.setFirstResult(0);
14584                    q.setMaxResults(2);
14585    
14586                    QueryPos qPos = QueryPos.getInstance(q);
14587    
14588                    qPos.add(groupId);
14589    
14590                    qPos.add(status);
14591    
14592                    if (orderByComparator != null) {
14593                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14594    
14595                            for (Object value : values) {
14596                                    qPos.add(value);
14597                            }
14598                    }
14599    
14600                    List<JournalArticle> list = q.list();
14601    
14602                    if (list.size() == 2) {
14603                            return list.get(1);
14604                    }
14605                    else {
14606                            return null;
14607                    }
14608            }
14609    
14610            /**
14611             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14612             *
14613             * @param groupId the group ID
14614             * @param status the status
14615             * @return the matching journal articles that the user has permission to view
14616             * @throws SystemException if a system exception occurred
14617             */
14618            @Override
14619            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
14620                    throws SystemException {
14621                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
14622                            QueryUtil.ALL_POS, null);
14623            }
14624    
14625            /**
14626             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14627             *
14628             * <p>
14629             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14630             * </p>
14631             *
14632             * @param groupId the group ID
14633             * @param status the status
14634             * @param start the lower bound of the range of journal articles
14635             * @param end the upper bound of the range of journal articles (not inclusive)
14636             * @return the range of matching journal articles that the user has permission to view
14637             * @throws SystemException if a system exception occurred
14638             */
14639            @Override
14640            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14641                    int start, int end) throws SystemException {
14642                    return filterFindByG_ST(groupId, status, start, end, null);
14643            }
14644    
14645            /**
14646             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
14647             *
14648             * <p>
14649             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14650             * </p>
14651             *
14652             * @param groupId the group ID
14653             * @param status the status
14654             * @param start the lower bound of the range of journal articles
14655             * @param end the upper bound of the range of journal articles (not inclusive)
14656             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14657             * @return the ordered range of matching journal articles that the user has permission to view
14658             * @throws SystemException if a system exception occurred
14659             */
14660            @Override
14661            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14662                    int start, int end, OrderByComparator orderByComparator)
14663                    throws SystemException {
14664                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14665                            return findByG_ST(groupId, status, start, end, orderByComparator);
14666                    }
14667    
14668                    StringBundler query = null;
14669    
14670                    if (orderByComparator != null) {
14671                            query = new StringBundler(4 +
14672                                            (orderByComparator.getOrderByFields().length * 3));
14673                    }
14674                    else {
14675                            query = new StringBundler(4);
14676                    }
14677    
14678                    if (getDB().isSupportsInlineDistinct()) {
14679                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14680                    }
14681                    else {
14682                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14683                    }
14684    
14685                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14686    
14687                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14688    
14689                    if (!getDB().isSupportsInlineDistinct()) {
14690                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14691                    }
14692    
14693                    if (orderByComparator != null) {
14694                            if (getDB().isSupportsInlineDistinct()) {
14695                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14696                                            orderByComparator, true);
14697                            }
14698                            else {
14699                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14700                                            orderByComparator, true);
14701                            }
14702                    }
14703                    else {
14704                            if (getDB().isSupportsInlineDistinct()) {
14705                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14706                            }
14707                            else {
14708                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14709                            }
14710                    }
14711    
14712                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14713                                    JournalArticle.class.getName(),
14714                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14715    
14716                    Session session = null;
14717    
14718                    try {
14719                            session = openSession();
14720    
14721                            SQLQuery q = session.createSQLQuery(sql);
14722    
14723                            if (getDB().isSupportsInlineDistinct()) {
14724                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14725                            }
14726                            else {
14727                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14728                            }
14729    
14730                            QueryPos qPos = QueryPos.getInstance(q);
14731    
14732                            qPos.add(groupId);
14733    
14734                            qPos.add(status);
14735    
14736                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14737                                    end);
14738                    }
14739                    catch (Exception e) {
14740                            throw processException(e);
14741                    }
14742                    finally {
14743                            closeSession(session);
14744                    }
14745            }
14746    
14747            /**
14748             * 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;.
14749             *
14750             * @param id the primary key of the current journal article
14751             * @param groupId the group ID
14752             * @param status the status
14753             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14754             * @return the previous, current, and next journal article
14755             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14756             * @throws SystemException if a system exception occurred
14757             */
14758            @Override
14759            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
14760                    int status, OrderByComparator orderByComparator)
14761                    throws NoSuchArticleException, SystemException {
14762                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14763                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
14764                    }
14765    
14766                    JournalArticle journalArticle = findByPrimaryKey(id);
14767    
14768                    Session session = null;
14769    
14770                    try {
14771                            session = openSession();
14772    
14773                            JournalArticle[] array = new JournalArticleImpl[3];
14774    
14775                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14776                                            groupId, status, orderByComparator, true);
14777    
14778                            array[1] = journalArticle;
14779    
14780                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14781                                            groupId, status, orderByComparator, false);
14782    
14783                            return array;
14784                    }
14785                    catch (Exception e) {
14786                            throw processException(e);
14787                    }
14788                    finally {
14789                            closeSession(session);
14790                    }
14791            }
14792    
14793            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
14794                    JournalArticle journalArticle, long groupId, int status,
14795                    OrderByComparator orderByComparator, boolean previous) {
14796                    StringBundler query = null;
14797    
14798                    if (orderByComparator != null) {
14799                            query = new StringBundler(6 +
14800                                            (orderByComparator.getOrderByFields().length * 6));
14801                    }
14802                    else {
14803                            query = new StringBundler(3);
14804                    }
14805    
14806                    if (getDB().isSupportsInlineDistinct()) {
14807                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14808                    }
14809                    else {
14810                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14811                    }
14812    
14813                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14814    
14815                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14816    
14817                    if (!getDB().isSupportsInlineDistinct()) {
14818                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14819                    }
14820    
14821                    if (orderByComparator != null) {
14822                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14823    
14824                            if (orderByConditionFields.length > 0) {
14825                                    query.append(WHERE_AND);
14826                            }
14827    
14828                            for (int i = 0; i < orderByConditionFields.length; i++) {
14829                                    if (getDB().isSupportsInlineDistinct()) {
14830                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14831                                    }
14832                                    else {
14833                                            query.append(_ORDER_BY_ENTITY_TABLE);
14834                                    }
14835    
14836                                    query.append(orderByConditionFields[i]);
14837    
14838                                    if ((i + 1) < orderByConditionFields.length) {
14839                                            if (orderByComparator.isAscending() ^ previous) {
14840                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14841                                            }
14842                                            else {
14843                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14844                                            }
14845                                    }
14846                                    else {
14847                                            if (orderByComparator.isAscending() ^ previous) {
14848                                                    query.append(WHERE_GREATER_THAN);
14849                                            }
14850                                            else {
14851                                                    query.append(WHERE_LESSER_THAN);
14852                                            }
14853                                    }
14854                            }
14855    
14856                            query.append(ORDER_BY_CLAUSE);
14857    
14858                            String[] orderByFields = orderByComparator.getOrderByFields();
14859    
14860                            for (int i = 0; i < orderByFields.length; i++) {
14861                                    if (getDB().isSupportsInlineDistinct()) {
14862                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14863                                    }
14864                                    else {
14865                                            query.append(_ORDER_BY_ENTITY_TABLE);
14866                                    }
14867    
14868                                    query.append(orderByFields[i]);
14869    
14870                                    if ((i + 1) < orderByFields.length) {
14871                                            if (orderByComparator.isAscending() ^ previous) {
14872                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14873                                            }
14874                                            else {
14875                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14876                                            }
14877                                    }
14878                                    else {
14879                                            if (orderByComparator.isAscending() ^ previous) {
14880                                                    query.append(ORDER_BY_ASC);
14881                                            }
14882                                            else {
14883                                                    query.append(ORDER_BY_DESC);
14884                                            }
14885                                    }
14886                            }
14887                    }
14888                    else {
14889                            if (getDB().isSupportsInlineDistinct()) {
14890                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14891                            }
14892                            else {
14893                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14894                            }
14895                    }
14896    
14897                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14898                                    JournalArticle.class.getName(),
14899                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14900    
14901                    SQLQuery q = session.createSQLQuery(sql);
14902    
14903                    q.setFirstResult(0);
14904                    q.setMaxResults(2);
14905    
14906                    if (getDB().isSupportsInlineDistinct()) {
14907                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14908                    }
14909                    else {
14910                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14911                    }
14912    
14913                    QueryPos qPos = QueryPos.getInstance(q);
14914    
14915                    qPos.add(groupId);
14916    
14917                    qPos.add(status);
14918    
14919                    if (orderByComparator != null) {
14920                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14921    
14922                            for (Object value : values) {
14923                                    qPos.add(value);
14924                            }
14925                    }
14926    
14927                    List<JournalArticle> list = q.list();
14928    
14929                    if (list.size() == 2) {
14930                            return list.get(1);
14931                    }
14932                    else {
14933                            return null;
14934                    }
14935            }
14936    
14937            /**
14938             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14939             *
14940             * @param groupId the group ID
14941             * @param status the status
14942             * @throws SystemException if a system exception occurred
14943             */
14944            @Override
14945            public void removeByG_ST(long groupId, int status)
14946                    throws SystemException {
14947                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
14948                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14949                            remove(journalArticle);
14950                    }
14951            }
14952    
14953            /**
14954             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
14955             *
14956             * @param groupId the group ID
14957             * @param status the status
14958             * @return the number of matching journal articles
14959             * @throws SystemException if a system exception occurred
14960             */
14961            @Override
14962            public int countByG_ST(long groupId, int status) throws SystemException {
14963                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
14964    
14965                    Object[] finderArgs = new Object[] { groupId, status };
14966    
14967                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14968                                    this);
14969    
14970                    if (count == null) {
14971                            StringBundler query = new StringBundler(3);
14972    
14973                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14974    
14975                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14976    
14977                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14978    
14979                            String sql = query.toString();
14980    
14981                            Session session = null;
14982    
14983                            try {
14984                                    session = openSession();
14985    
14986                                    Query q = session.createQuery(sql);
14987    
14988                                    QueryPos qPos = QueryPos.getInstance(q);
14989    
14990                                    qPos.add(groupId);
14991    
14992                                    qPos.add(status);
14993    
14994                                    count = (Long)q.uniqueResult();
14995    
14996                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14997                            }
14998                            catch (Exception e) {
14999                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15000    
15001                                    throw processException(e);
15002                            }
15003                            finally {
15004                                    closeSession(session);
15005                            }
15006                    }
15007    
15008                    return count.intValue();
15009            }
15010    
15011            /**
15012             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
15013             *
15014             * @param groupId the group ID
15015             * @param status the status
15016             * @return the number of matching journal articles that the user has permission to view
15017             * @throws SystemException if a system exception occurred
15018             */
15019            @Override
15020            public int filterCountByG_ST(long groupId, int status)
15021                    throws SystemException {
15022                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15023                            return countByG_ST(groupId, status);
15024                    }
15025    
15026                    StringBundler query = new StringBundler(3);
15027    
15028                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15029    
15030                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15031    
15032                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15033    
15034                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15035                                    JournalArticle.class.getName(),
15036                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15037    
15038                    Session session = null;
15039    
15040                    try {
15041                            session = openSession();
15042    
15043                            SQLQuery q = session.createSQLQuery(sql);
15044    
15045                            q.addScalar(COUNT_COLUMN_NAME,
15046                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15047    
15048                            QueryPos qPos = QueryPos.getInstance(q);
15049    
15050                            qPos.add(groupId);
15051    
15052                            qPos.add(status);
15053    
15054                            Long count = (Long)q.uniqueResult();
15055    
15056                            return count.intValue();
15057                    }
15058                    catch (Exception e) {
15059                            throw processException(e);
15060                    }
15061                    finally {
15062                            closeSession(session);
15063                    }
15064            }
15065    
15066            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
15067            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
15068            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15069                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15070                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15071                            "findByC_V",
15072                            new String[] {
15073                                    Long.class.getName(), Double.class.getName(),
15074                                    
15075                            Integer.class.getName(), Integer.class.getName(),
15076                                    OrderByComparator.class.getName()
15077                            });
15078            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15079                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15080                            JournalArticleImpl.class,
15081                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
15082                            new String[] { Long.class.getName(), Double.class.getName() },
15083                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15084                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
15085                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
15086            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15087                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
15089                            new String[] { Long.class.getName(), Double.class.getName() });
15090    
15091            /**
15092             * Returns all the journal articles where companyId = &#63; and version = &#63;.
15093             *
15094             * @param companyId the company ID
15095             * @param version the version
15096             * @return the matching journal articles
15097             * @throws SystemException if a system exception occurred
15098             */
15099            @Override
15100            public List<JournalArticle> findByC_V(long companyId, double version)
15101                    throws SystemException {
15102                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
15103                            QueryUtil.ALL_POS, null);
15104            }
15105    
15106            /**
15107             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
15108             *
15109             * <p>
15110             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15111             * </p>
15112             *
15113             * @param companyId the company ID
15114             * @param version the version
15115             * @param start the lower bound of the range of journal articles
15116             * @param end the upper bound of the range of journal articles (not inclusive)
15117             * @return the range of matching journal articles
15118             * @throws SystemException if a system exception occurred
15119             */
15120            @Override
15121            public List<JournalArticle> findByC_V(long companyId, double version,
15122                    int start, int end) throws SystemException {
15123                    return findByC_V(companyId, version, start, end, null);
15124            }
15125    
15126            /**
15127             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
15128             *
15129             * <p>
15130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15131             * </p>
15132             *
15133             * @param companyId the company ID
15134             * @param version the version
15135             * @param start the lower bound of the range of journal articles
15136             * @param end the upper bound of the range of journal articles (not inclusive)
15137             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15138             * @return the ordered range of matching journal articles
15139             * @throws SystemException if a system exception occurred
15140             */
15141            @Override
15142            public List<JournalArticle> findByC_V(long companyId, double version,
15143                    int start, int end, OrderByComparator orderByComparator)
15144                    throws SystemException {
15145                    boolean pagination = true;
15146                    FinderPath finderPath = null;
15147                    Object[] finderArgs = null;
15148    
15149                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15150                                    (orderByComparator == null)) {
15151                            pagination = false;
15152                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
15153                            finderArgs = new Object[] { companyId, version };
15154                    }
15155                    else {
15156                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
15157                            finderArgs = new Object[] {
15158                                            companyId, version,
15159                                            
15160                                            start, end, orderByComparator
15161                                    };
15162                    }
15163    
15164                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15165                                    finderArgs, this);
15166    
15167                    if ((list != null) && !list.isEmpty()) {
15168                            for (JournalArticle journalArticle : list) {
15169                                    if ((companyId != journalArticle.getCompanyId()) ||
15170                                                    (version != journalArticle.getVersion())) {
15171                                            list = null;
15172    
15173                                            break;
15174                                    }
15175                            }
15176                    }
15177    
15178                    if (list == null) {
15179                            StringBundler query = null;
15180    
15181                            if (orderByComparator != null) {
15182                                    query = new StringBundler(4 +
15183                                                    (orderByComparator.getOrderByFields().length * 3));
15184                            }
15185                            else {
15186                                    query = new StringBundler(4);
15187                            }
15188    
15189                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15190    
15191                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15192    
15193                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15194    
15195                            if (orderByComparator != null) {
15196                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15197                                            orderByComparator);
15198                            }
15199                            else
15200                             if (pagination) {
15201                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15202                            }
15203    
15204                            String sql = query.toString();
15205    
15206                            Session session = null;
15207    
15208                            try {
15209                                    session = openSession();
15210    
15211                                    Query q = session.createQuery(sql);
15212    
15213                                    QueryPos qPos = QueryPos.getInstance(q);
15214    
15215                                    qPos.add(companyId);
15216    
15217                                    qPos.add(version);
15218    
15219                                    if (!pagination) {
15220                                            list = (List<JournalArticle>)QueryUtil.list(q,
15221                                                            getDialect(), start, end, false);
15222    
15223                                            Collections.sort(list);
15224    
15225                                            list = new UnmodifiableList<JournalArticle>(list);
15226                                    }
15227                                    else {
15228                                            list = (List<JournalArticle>)QueryUtil.list(q,
15229                                                            getDialect(), start, end);
15230                                    }
15231    
15232                                    cacheResult(list);
15233    
15234                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15235                            }
15236                            catch (Exception e) {
15237                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15238    
15239                                    throw processException(e);
15240                            }
15241                            finally {
15242                                    closeSession(session);
15243                            }
15244                    }
15245    
15246                    return list;
15247            }
15248    
15249            /**
15250             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15251             *
15252             * @param companyId the company ID
15253             * @param version the version
15254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15255             * @return the first matching journal article
15256             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15257             * @throws SystemException if a system exception occurred
15258             */
15259            @Override
15260            public JournalArticle findByC_V_First(long companyId, double version,
15261                    OrderByComparator orderByComparator)
15262                    throws NoSuchArticleException, SystemException {
15263                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
15264                                    orderByComparator);
15265    
15266                    if (journalArticle != null) {
15267                            return journalArticle;
15268                    }
15269    
15270                    StringBundler msg = new StringBundler(6);
15271    
15272                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15273    
15274                    msg.append("companyId=");
15275                    msg.append(companyId);
15276    
15277                    msg.append(", version=");
15278                    msg.append(version);
15279    
15280                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15281    
15282                    throw new NoSuchArticleException(msg.toString());
15283            }
15284    
15285            /**
15286             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15287             *
15288             * @param companyId the company ID
15289             * @param version the version
15290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15291             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15292             * @throws SystemException if a system exception occurred
15293             */
15294            @Override
15295            public JournalArticle fetchByC_V_First(long companyId, double version,
15296                    OrderByComparator orderByComparator) throws SystemException {
15297                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
15298                                    orderByComparator);
15299    
15300                    if (!list.isEmpty()) {
15301                            return list.get(0);
15302                    }
15303    
15304                    return null;
15305            }
15306    
15307            /**
15308             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15309             *
15310             * @param companyId the company ID
15311             * @param version the version
15312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15313             * @return the last matching journal article
15314             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15315             * @throws SystemException if a system exception occurred
15316             */
15317            @Override
15318            public JournalArticle findByC_V_Last(long companyId, double version,
15319                    OrderByComparator orderByComparator)
15320                    throws NoSuchArticleException, SystemException {
15321                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
15322                                    orderByComparator);
15323    
15324                    if (journalArticle != null) {
15325                            return journalArticle;
15326                    }
15327    
15328                    StringBundler msg = new StringBundler(6);
15329    
15330                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15331    
15332                    msg.append("companyId=");
15333                    msg.append(companyId);
15334    
15335                    msg.append(", version=");
15336                    msg.append(version);
15337    
15338                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15339    
15340                    throw new NoSuchArticleException(msg.toString());
15341            }
15342    
15343            /**
15344             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15345             *
15346             * @param companyId the company ID
15347             * @param version the version
15348             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15349             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15350             * @throws SystemException if a system exception occurred
15351             */
15352            @Override
15353            public JournalArticle fetchByC_V_Last(long companyId, double version,
15354                    OrderByComparator orderByComparator) throws SystemException {
15355                    int count = countByC_V(companyId, version);
15356    
15357                    if (count == 0) {
15358                            return null;
15359                    }
15360    
15361                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
15362                                    count, orderByComparator);
15363    
15364                    if (!list.isEmpty()) {
15365                            return list.get(0);
15366                    }
15367    
15368                    return null;
15369            }
15370    
15371            /**
15372             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
15373             *
15374             * @param id the primary key of the current journal article
15375             * @param companyId the company ID
15376             * @param version the version
15377             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15378             * @return the previous, current, and next journal article
15379             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15380             * @throws SystemException if a system exception occurred
15381             */
15382            @Override
15383            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
15384                    double version, OrderByComparator orderByComparator)
15385                    throws NoSuchArticleException, SystemException {
15386                    JournalArticle journalArticle = findByPrimaryKey(id);
15387    
15388                    Session session = null;
15389    
15390                    try {
15391                            session = openSession();
15392    
15393                            JournalArticle[] array = new JournalArticleImpl[3];
15394    
15395                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15396                                            version, orderByComparator, true);
15397    
15398                            array[1] = journalArticle;
15399    
15400                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15401                                            version, orderByComparator, false);
15402    
15403                            return array;
15404                    }
15405                    catch (Exception e) {
15406                            throw processException(e);
15407                    }
15408                    finally {
15409                            closeSession(session);
15410                    }
15411            }
15412    
15413            protected JournalArticle getByC_V_PrevAndNext(Session session,
15414                    JournalArticle journalArticle, long companyId, double version,
15415                    OrderByComparator orderByComparator, boolean previous) {
15416                    StringBundler query = null;
15417    
15418                    if (orderByComparator != null) {
15419                            query = new StringBundler(6 +
15420                                            (orderByComparator.getOrderByFields().length * 6));
15421                    }
15422                    else {
15423                            query = new StringBundler(3);
15424                    }
15425    
15426                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15427    
15428                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15429    
15430                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
15431    
15432                    if (orderByComparator != null) {
15433                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15434    
15435                            if (orderByConditionFields.length > 0) {
15436                                    query.append(WHERE_AND);
15437                            }
15438    
15439                            for (int i = 0; i < orderByConditionFields.length; i++) {
15440                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15441                                    query.append(orderByConditionFields[i]);
15442    
15443                                    if ((i + 1) < orderByConditionFields.length) {
15444                                            if (orderByComparator.isAscending() ^ previous) {
15445                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15446                                            }
15447                                            else {
15448                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15449                                            }
15450                                    }
15451                                    else {
15452                                            if (orderByComparator.isAscending() ^ previous) {
15453                                                    query.append(WHERE_GREATER_THAN);
15454                                            }
15455                                            else {
15456                                                    query.append(WHERE_LESSER_THAN);
15457                                            }
15458                                    }
15459                            }
15460    
15461                            query.append(ORDER_BY_CLAUSE);
15462    
15463                            String[] orderByFields = orderByComparator.getOrderByFields();
15464    
15465                            for (int i = 0; i < orderByFields.length; i++) {
15466                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15467                                    query.append(orderByFields[i]);
15468    
15469                                    if ((i + 1) < orderByFields.length) {
15470                                            if (orderByComparator.isAscending() ^ previous) {
15471                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15472                                            }
15473                                            else {
15474                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15475                                            }
15476                                    }
15477                                    else {
15478                                            if (orderByComparator.isAscending() ^ previous) {
15479                                                    query.append(ORDER_BY_ASC);
15480                                            }
15481                                            else {
15482                                                    query.append(ORDER_BY_DESC);
15483                                            }
15484                                    }
15485                            }
15486                    }
15487                    else {
15488                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15489                    }
15490    
15491                    String sql = query.toString();
15492    
15493                    Query q = session.createQuery(sql);
15494    
15495                    q.setFirstResult(0);
15496                    q.setMaxResults(2);
15497    
15498                    QueryPos qPos = QueryPos.getInstance(q);
15499    
15500                    qPos.add(companyId);
15501    
15502                    qPos.add(version);
15503    
15504                    if (orderByComparator != null) {
15505                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15506    
15507                            for (Object value : values) {
15508                                    qPos.add(value);
15509                            }
15510                    }
15511    
15512                    List<JournalArticle> list = q.list();
15513    
15514                    if (list.size() == 2) {
15515                            return list.get(1);
15516                    }
15517                    else {
15518                            return null;
15519                    }
15520            }
15521    
15522            /**
15523             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
15524             *
15525             * @param companyId the company ID
15526             * @param version the version
15527             * @throws SystemException if a system exception occurred
15528             */
15529            @Override
15530            public void removeByC_V(long companyId, double version)
15531                    throws SystemException {
15532                    for (JournalArticle journalArticle : findByC_V(companyId, version,
15533                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15534                            remove(journalArticle);
15535                    }
15536            }
15537    
15538            /**
15539             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15540             *
15541             * @param companyId the company ID
15542             * @param version the version
15543             * @return the number of matching journal articles
15544             * @throws SystemException if a system exception occurred
15545             */
15546            @Override
15547            public int countByC_V(long companyId, double version)
15548                    throws SystemException {
15549                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
15550    
15551                    Object[] finderArgs = new Object[] { companyId, version };
15552    
15553                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15554                                    this);
15555    
15556                    if (count == null) {
15557                            StringBundler query = new StringBundler(3);
15558    
15559                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15560    
15561                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15562    
15563                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15564    
15565                            String sql = query.toString();
15566    
15567                            Session session = null;
15568    
15569                            try {
15570                                    session = openSession();
15571    
15572                                    Query q = session.createQuery(sql);
15573    
15574                                    QueryPos qPos = QueryPos.getInstance(q);
15575    
15576                                    qPos.add(companyId);
15577    
15578                                    qPos.add(version);
15579    
15580                                    count = (Long)q.uniqueResult();
15581    
15582                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15583                            }
15584                            catch (Exception e) {
15585                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15586    
15587                                    throw processException(e);
15588                            }
15589                            finally {
15590                                    closeSession(session);
15591                            }
15592                    }
15593    
15594                    return count.intValue();
15595            }
15596    
15597            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15598            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
15599            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15600                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15601                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15602                            "findByC_ST",
15603                            new String[] {
15604                                    Long.class.getName(), Integer.class.getName(),
15605                                    
15606                            Integer.class.getName(), Integer.class.getName(),
15607                                    OrderByComparator.class.getName()
15608                            });
15609            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15610                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15611                            JournalArticleImpl.class,
15612                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
15613                            new String[] { Long.class.getName(), Integer.class.getName() },
15614                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15615                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
15616                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
15617                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
15618            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15619                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15620                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
15621                            new String[] { Long.class.getName(), Integer.class.getName() });
15622    
15623            /**
15624             * Returns all the journal articles where companyId = &#63; and status = &#63;.
15625             *
15626             * @param companyId the company ID
15627             * @param status the status
15628             * @return the matching journal articles
15629             * @throws SystemException if a system exception occurred
15630             */
15631            @Override
15632            public List<JournalArticle> findByC_ST(long companyId, int status)
15633                    throws SystemException {
15634                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
15635                            QueryUtil.ALL_POS, null);
15636            }
15637    
15638            /**
15639             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
15640             *
15641             * <p>
15642             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15643             * </p>
15644             *
15645             * @param companyId the company ID
15646             * @param status the status
15647             * @param start the lower bound of the range of journal articles
15648             * @param end the upper bound of the range of journal articles (not inclusive)
15649             * @return the range of matching journal articles
15650             * @throws SystemException if a system exception occurred
15651             */
15652            @Override
15653            public List<JournalArticle> findByC_ST(long companyId, int status,
15654                    int start, int end) throws SystemException {
15655                    return findByC_ST(companyId, status, start, end, null);
15656            }
15657    
15658            /**
15659             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
15660             *
15661             * <p>
15662             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15663             * </p>
15664             *
15665             * @param companyId the company ID
15666             * @param status the status
15667             * @param start the lower bound of the range of journal articles
15668             * @param end the upper bound of the range of journal articles (not inclusive)
15669             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15670             * @return the ordered range of matching journal articles
15671             * @throws SystemException if a system exception occurred
15672             */
15673            @Override
15674            public List<JournalArticle> findByC_ST(long companyId, int status,
15675                    int start, int end, OrderByComparator orderByComparator)
15676                    throws SystemException {
15677                    boolean pagination = true;
15678                    FinderPath finderPath = null;
15679                    Object[] finderArgs = null;
15680    
15681                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15682                                    (orderByComparator == null)) {
15683                            pagination = false;
15684                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
15685                            finderArgs = new Object[] { companyId, status };
15686                    }
15687                    else {
15688                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
15689                            finderArgs = new Object[] {
15690                                            companyId, status,
15691                                            
15692                                            start, end, orderByComparator
15693                                    };
15694                    }
15695    
15696                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15697                                    finderArgs, this);
15698    
15699                    if ((list != null) && !list.isEmpty()) {
15700                            for (JournalArticle journalArticle : list) {
15701                                    if ((companyId != journalArticle.getCompanyId()) ||
15702                                                    (status != journalArticle.getStatus())) {
15703                                            list = null;
15704    
15705                                            break;
15706                                    }
15707                            }
15708                    }
15709    
15710                    if (list == null) {
15711                            StringBundler query = null;
15712    
15713                            if (orderByComparator != null) {
15714                                    query = new StringBundler(4 +
15715                                                    (orderByComparator.getOrderByFields().length * 3));
15716                            }
15717                            else {
15718                                    query = new StringBundler(4);
15719                            }
15720    
15721                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15722    
15723                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15724    
15725                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15726    
15727                            if (orderByComparator != null) {
15728                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15729                                            orderByComparator);
15730                            }
15731                            else
15732                             if (pagination) {
15733                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15734                            }
15735    
15736                            String sql = query.toString();
15737    
15738                            Session session = null;
15739    
15740                            try {
15741                                    session = openSession();
15742    
15743                                    Query q = session.createQuery(sql);
15744    
15745                                    QueryPos qPos = QueryPos.getInstance(q);
15746    
15747                                    qPos.add(companyId);
15748    
15749                                    qPos.add(status);
15750    
15751                                    if (!pagination) {
15752                                            list = (List<JournalArticle>)QueryUtil.list(q,
15753                                                            getDialect(), start, end, false);
15754    
15755                                            Collections.sort(list);
15756    
15757                                            list = new UnmodifiableList<JournalArticle>(list);
15758                                    }
15759                                    else {
15760                                            list = (List<JournalArticle>)QueryUtil.list(q,
15761                                                            getDialect(), start, end);
15762                                    }
15763    
15764                                    cacheResult(list);
15765    
15766                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15767                            }
15768                            catch (Exception e) {
15769                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15770    
15771                                    throw processException(e);
15772                            }
15773                            finally {
15774                                    closeSession(session);
15775                            }
15776                    }
15777    
15778                    return list;
15779            }
15780    
15781            /**
15782             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15783             *
15784             * @param companyId the company ID
15785             * @param status the status
15786             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15787             * @return the first matching journal article
15788             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15789             * @throws SystemException if a system exception occurred
15790             */
15791            @Override
15792            public JournalArticle findByC_ST_First(long companyId, int status,
15793                    OrderByComparator orderByComparator)
15794                    throws NoSuchArticleException, SystemException {
15795                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
15796                                    orderByComparator);
15797    
15798                    if (journalArticle != null) {
15799                            return journalArticle;
15800                    }
15801    
15802                    StringBundler msg = new StringBundler(6);
15803    
15804                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15805    
15806                    msg.append("companyId=");
15807                    msg.append(companyId);
15808    
15809                    msg.append(", status=");
15810                    msg.append(status);
15811    
15812                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15813    
15814                    throw new NoSuchArticleException(msg.toString());
15815            }
15816    
15817            /**
15818             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15819             *
15820             * @param companyId the company ID
15821             * @param status the status
15822             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15823             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15824             * @throws SystemException if a system exception occurred
15825             */
15826            @Override
15827            public JournalArticle fetchByC_ST_First(long companyId, int status,
15828                    OrderByComparator orderByComparator) throws SystemException {
15829                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
15830                                    orderByComparator);
15831    
15832                    if (!list.isEmpty()) {
15833                            return list.get(0);
15834                    }
15835    
15836                    return null;
15837            }
15838    
15839            /**
15840             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15841             *
15842             * @param companyId the company ID
15843             * @param status the status
15844             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15845             * @return the last matching journal article
15846             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15847             * @throws SystemException if a system exception occurred
15848             */
15849            @Override
15850            public JournalArticle findByC_ST_Last(long companyId, int status,
15851                    OrderByComparator orderByComparator)
15852                    throws NoSuchArticleException, SystemException {
15853                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
15854                                    orderByComparator);
15855    
15856                    if (journalArticle != null) {
15857                            return journalArticle;
15858                    }
15859    
15860                    StringBundler msg = new StringBundler(6);
15861    
15862                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15863    
15864                    msg.append("companyId=");
15865                    msg.append(companyId);
15866    
15867                    msg.append(", status=");
15868                    msg.append(status);
15869    
15870                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15871    
15872                    throw new NoSuchArticleException(msg.toString());
15873            }
15874    
15875            /**
15876             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15877             *
15878             * @param companyId the company ID
15879             * @param status the status
15880             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15881             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15882             * @throws SystemException if a system exception occurred
15883             */
15884            @Override
15885            public JournalArticle fetchByC_ST_Last(long companyId, int status,
15886                    OrderByComparator orderByComparator) throws SystemException {
15887                    int count = countByC_ST(companyId, status);
15888    
15889                    if (count == 0) {
15890                            return null;
15891                    }
15892    
15893                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
15894                                    count, orderByComparator);
15895    
15896                    if (!list.isEmpty()) {
15897                            return list.get(0);
15898                    }
15899    
15900                    return null;
15901            }
15902    
15903            /**
15904             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
15905             *
15906             * @param id the primary key of the current journal article
15907             * @param companyId the company ID
15908             * @param status the status
15909             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15910             * @return the previous, current, and next journal article
15911             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15912             * @throws SystemException if a system exception occurred
15913             */
15914            @Override
15915            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
15916                    int status, OrderByComparator orderByComparator)
15917                    throws NoSuchArticleException, SystemException {
15918                    JournalArticle journalArticle = findByPrimaryKey(id);
15919    
15920                    Session session = null;
15921    
15922                    try {
15923                            session = openSession();
15924    
15925                            JournalArticle[] array = new JournalArticleImpl[3];
15926    
15927                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
15928                                            companyId, status, orderByComparator, true);
15929    
15930                            array[1] = journalArticle;
15931    
15932                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
15933                                            companyId, status, orderByComparator, false);
15934    
15935                            return array;
15936                    }
15937                    catch (Exception e) {
15938                            throw processException(e);
15939                    }
15940                    finally {
15941                            closeSession(session);
15942                    }
15943            }
15944    
15945            protected JournalArticle getByC_ST_PrevAndNext(Session session,
15946                    JournalArticle journalArticle, long companyId, int status,
15947                    OrderByComparator orderByComparator, boolean previous) {
15948                    StringBundler query = null;
15949    
15950                    if (orderByComparator != null) {
15951                            query = new StringBundler(6 +
15952                                            (orderByComparator.getOrderByFields().length * 6));
15953                    }
15954                    else {
15955                            query = new StringBundler(3);
15956                    }
15957    
15958                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15959    
15960                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15961    
15962                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15963    
15964                    if (orderByComparator != null) {
15965                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15966    
15967                            if (orderByConditionFields.length > 0) {
15968                                    query.append(WHERE_AND);
15969                            }
15970    
15971                            for (int i = 0; i < orderByConditionFields.length; i++) {
15972                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15973                                    query.append(orderByConditionFields[i]);
15974    
15975                                    if ((i + 1) < orderByConditionFields.length) {
15976                                            if (orderByComparator.isAscending() ^ previous) {
15977                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15978                                            }
15979                                            else {
15980                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15981                                            }
15982                                    }
15983                                    else {
15984                                            if (orderByComparator.isAscending() ^ previous) {
15985                                                    query.append(WHERE_GREATER_THAN);
15986                                            }
15987                                            else {
15988                                                    query.append(WHERE_LESSER_THAN);
15989                                            }
15990                                    }
15991                            }
15992    
15993                            query.append(ORDER_BY_CLAUSE);
15994    
15995                            String[] orderByFields = orderByComparator.getOrderByFields();
15996    
15997                            for (int i = 0; i < orderByFields.length; i++) {
15998                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15999                                    query.append(orderByFields[i]);
16000    
16001                                    if ((i + 1) < orderByFields.length) {
16002                                            if (orderByComparator.isAscending() ^ previous) {
16003                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16004                                            }
16005                                            else {
16006                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16007                                            }
16008                                    }
16009                                    else {
16010                                            if (orderByComparator.isAscending() ^ previous) {
16011                                                    query.append(ORDER_BY_ASC);
16012                                            }
16013                                            else {
16014                                                    query.append(ORDER_BY_DESC);
16015                                            }
16016                                    }
16017                            }
16018                    }
16019                    else {
16020                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16021                    }
16022    
16023                    String sql = query.toString();
16024    
16025                    Query q = session.createQuery(sql);
16026    
16027                    q.setFirstResult(0);
16028                    q.setMaxResults(2);
16029    
16030                    QueryPos qPos = QueryPos.getInstance(q);
16031    
16032                    qPos.add(companyId);
16033    
16034                    qPos.add(status);
16035    
16036                    if (orderByComparator != null) {
16037                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16038    
16039                            for (Object value : values) {
16040                                    qPos.add(value);
16041                            }
16042                    }
16043    
16044                    List<JournalArticle> list = q.list();
16045    
16046                    if (list.size() == 2) {
16047                            return list.get(1);
16048                    }
16049                    else {
16050                            return null;
16051                    }
16052            }
16053    
16054            /**
16055             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
16056             *
16057             * @param companyId the company ID
16058             * @param status the status
16059             * @throws SystemException if a system exception occurred
16060             */
16061            @Override
16062            public void removeByC_ST(long companyId, int status)
16063                    throws SystemException {
16064                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
16065                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16066                            remove(journalArticle);
16067                    }
16068            }
16069    
16070            /**
16071             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
16072             *
16073             * @param companyId the company ID
16074             * @param status the status
16075             * @return the number of matching journal articles
16076             * @throws SystemException if a system exception occurred
16077             */
16078            @Override
16079            public int countByC_ST(long companyId, int status)
16080                    throws SystemException {
16081                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
16082    
16083                    Object[] finderArgs = new Object[] { companyId, status };
16084    
16085                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16086                                    this);
16087    
16088                    if (count == null) {
16089                            StringBundler query = new StringBundler(3);
16090    
16091                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16092    
16093                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16094    
16095                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16096    
16097                            String sql = query.toString();
16098    
16099                            Session session = null;
16100    
16101                            try {
16102                                    session = openSession();
16103    
16104                                    Query q = session.createQuery(sql);
16105    
16106                                    QueryPos qPos = QueryPos.getInstance(q);
16107    
16108                                    qPos.add(companyId);
16109    
16110                                    qPos.add(status);
16111    
16112                                    count = (Long)q.uniqueResult();
16113    
16114                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16115                            }
16116                            catch (Exception e) {
16117                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16118    
16119                                    throw processException(e);
16120                            }
16121                            finally {
16122                                    closeSession(session);
16123                            }
16124                    }
16125    
16126                    return count.intValue();
16127            }
16128    
16129            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16130            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
16131            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16132                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16133                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16134                            "findByC_NotST",
16135                            new String[] {
16136                                    Long.class.getName(), Integer.class.getName(),
16137                                    
16138                            Integer.class.getName(), Integer.class.getName(),
16139                                    OrderByComparator.class.getName()
16140                            });
16141            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16142                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16143                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotST",
16144                            new String[] { Long.class.getName(), Integer.class.getName() });
16145    
16146            /**
16147             * Returns all the journal articles where companyId = &#63; and status &ne; &#63;.
16148             *
16149             * @param companyId the company ID
16150             * @param status the status
16151             * @return the matching journal articles
16152             * @throws SystemException if a system exception occurred
16153             */
16154            @Override
16155            public List<JournalArticle> findByC_NotST(long companyId, int status)
16156                    throws SystemException {
16157                    return findByC_NotST(companyId, status, QueryUtil.ALL_POS,
16158                            QueryUtil.ALL_POS, null);
16159            }
16160    
16161            /**
16162             * Returns a range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16163             *
16164             * <p>
16165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16166             * </p>
16167             *
16168             * @param companyId the company ID
16169             * @param status the status
16170             * @param start the lower bound of the range of journal articles
16171             * @param end the upper bound of the range of journal articles (not inclusive)
16172             * @return the range of matching journal articles
16173             * @throws SystemException if a system exception occurred
16174             */
16175            @Override
16176            public List<JournalArticle> findByC_NotST(long companyId, int status,
16177                    int start, int end) throws SystemException {
16178                    return findByC_NotST(companyId, status, start, end, null);
16179            }
16180    
16181            /**
16182             * Returns an ordered range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16183             *
16184             * <p>
16185             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16186             * </p>
16187             *
16188             * @param companyId the company ID
16189             * @param status the status
16190             * @param start the lower bound of the range of journal articles
16191             * @param end the upper bound of the range of journal articles (not inclusive)
16192             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16193             * @return the ordered range of matching journal articles
16194             * @throws SystemException if a system exception occurred
16195             */
16196            @Override
16197            public List<JournalArticle> findByC_NotST(long companyId, int status,
16198                    int start, int end, OrderByComparator orderByComparator)
16199                    throws SystemException {
16200                    boolean pagination = true;
16201                    FinderPath finderPath = null;
16202                    Object[] finderArgs = null;
16203    
16204                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST;
16205                    finderArgs = new Object[] {
16206                                    companyId, status,
16207                                    
16208                                    start, end, orderByComparator
16209                            };
16210    
16211                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16212                                    finderArgs, this);
16213    
16214                    if ((list != null) && !list.isEmpty()) {
16215                            for (JournalArticle journalArticle : list) {
16216                                    if ((companyId != journalArticle.getCompanyId()) ||
16217                                                    (status == journalArticle.getStatus())) {
16218                                            list = null;
16219    
16220                                            break;
16221                                    }
16222                            }
16223                    }
16224    
16225                    if (list == null) {
16226                            StringBundler query = null;
16227    
16228                            if (orderByComparator != null) {
16229                                    query = new StringBundler(4 +
16230                                                    (orderByComparator.getOrderByFields().length * 3));
16231                            }
16232                            else {
16233                                    query = new StringBundler(4);
16234                            }
16235    
16236                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16237    
16238                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16239    
16240                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16241    
16242                            if (orderByComparator != null) {
16243                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16244                                            orderByComparator);
16245                            }
16246                            else
16247                             if (pagination) {
16248                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16249                            }
16250    
16251                            String sql = query.toString();
16252    
16253                            Session session = null;
16254    
16255                            try {
16256                                    session = openSession();
16257    
16258                                    Query q = session.createQuery(sql);
16259    
16260                                    QueryPos qPos = QueryPos.getInstance(q);
16261    
16262                                    qPos.add(companyId);
16263    
16264                                    qPos.add(status);
16265    
16266                                    if (!pagination) {
16267                                            list = (List<JournalArticle>)QueryUtil.list(q,
16268                                                            getDialect(), start, end, false);
16269    
16270                                            Collections.sort(list);
16271    
16272                                            list = new UnmodifiableList<JournalArticle>(list);
16273                                    }
16274                                    else {
16275                                            list = (List<JournalArticle>)QueryUtil.list(q,
16276                                                            getDialect(), start, end);
16277                                    }
16278    
16279                                    cacheResult(list);
16280    
16281                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16282                            }
16283                            catch (Exception e) {
16284                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16285    
16286                                    throw processException(e);
16287                            }
16288                            finally {
16289                                    closeSession(session);
16290                            }
16291                    }
16292    
16293                    return list;
16294            }
16295    
16296            /**
16297             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16298             *
16299             * @param companyId the company ID
16300             * @param status the status
16301             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16302             * @return the first matching journal article
16303             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16304             * @throws SystemException if a system exception occurred
16305             */
16306            @Override
16307            public JournalArticle findByC_NotST_First(long companyId, int status,
16308                    OrderByComparator orderByComparator)
16309                    throws NoSuchArticleException, SystemException {
16310                    JournalArticle journalArticle = fetchByC_NotST_First(companyId, status,
16311                                    orderByComparator);
16312    
16313                    if (journalArticle != null) {
16314                            return journalArticle;
16315                    }
16316    
16317                    StringBundler msg = new StringBundler(6);
16318    
16319                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16320    
16321                    msg.append("companyId=");
16322                    msg.append(companyId);
16323    
16324                    msg.append(", status=");
16325                    msg.append(status);
16326    
16327                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16328    
16329                    throw new NoSuchArticleException(msg.toString());
16330            }
16331    
16332            /**
16333             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16334             *
16335             * @param companyId the company ID
16336             * @param status the status
16337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16338             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16339             * @throws SystemException if a system exception occurred
16340             */
16341            @Override
16342            public JournalArticle fetchByC_NotST_First(long companyId, int status,
16343                    OrderByComparator orderByComparator) throws SystemException {
16344                    List<JournalArticle> list = findByC_NotST(companyId, status, 0, 1,
16345                                    orderByComparator);
16346    
16347                    if (!list.isEmpty()) {
16348                            return list.get(0);
16349                    }
16350    
16351                    return null;
16352            }
16353    
16354            /**
16355             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16356             *
16357             * @param companyId the company ID
16358             * @param status the status
16359             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16360             * @return the last matching journal article
16361             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16362             * @throws SystemException if a system exception occurred
16363             */
16364            @Override
16365            public JournalArticle findByC_NotST_Last(long companyId, int status,
16366                    OrderByComparator orderByComparator)
16367                    throws NoSuchArticleException, SystemException {
16368                    JournalArticle journalArticle = fetchByC_NotST_Last(companyId, status,
16369                                    orderByComparator);
16370    
16371                    if (journalArticle != null) {
16372                            return journalArticle;
16373                    }
16374    
16375                    StringBundler msg = new StringBundler(6);
16376    
16377                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16378    
16379                    msg.append("companyId=");
16380                    msg.append(companyId);
16381    
16382                    msg.append(", status=");
16383                    msg.append(status);
16384    
16385                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16386    
16387                    throw new NoSuchArticleException(msg.toString());
16388            }
16389    
16390            /**
16391             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16392             *
16393             * @param companyId the company ID
16394             * @param status the status
16395             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16396             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16397             * @throws SystemException if a system exception occurred
16398             */
16399            @Override
16400            public JournalArticle fetchByC_NotST_Last(long companyId, int status,
16401                    OrderByComparator orderByComparator) throws SystemException {
16402                    int count = countByC_NotST(companyId, status);
16403    
16404                    if (count == 0) {
16405                            return null;
16406                    }
16407    
16408                    List<JournalArticle> list = findByC_NotST(companyId, status, count - 1,
16409                                    count, orderByComparator);
16410    
16411                    if (!list.isEmpty()) {
16412                            return list.get(0);
16413                    }
16414    
16415                    return null;
16416            }
16417    
16418            /**
16419             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16420             *
16421             * @param id the primary key of the current journal article
16422             * @param companyId the company ID
16423             * @param status the status
16424             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16425             * @return the previous, current, and next journal article
16426             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16427             * @throws SystemException if a system exception occurred
16428             */
16429            @Override
16430            public JournalArticle[] findByC_NotST_PrevAndNext(long id, long companyId,
16431                    int status, OrderByComparator orderByComparator)
16432                    throws NoSuchArticleException, SystemException {
16433                    JournalArticle journalArticle = findByPrimaryKey(id);
16434    
16435                    Session session = null;
16436    
16437                    try {
16438                            session = openSession();
16439    
16440                            JournalArticle[] array = new JournalArticleImpl[3];
16441    
16442                            array[0] = getByC_NotST_PrevAndNext(session, journalArticle,
16443                                            companyId, status, orderByComparator, true);
16444    
16445                            array[1] = journalArticle;
16446    
16447                            array[2] = getByC_NotST_PrevAndNext(session, journalArticle,
16448                                            companyId, status, orderByComparator, false);
16449    
16450                            return array;
16451                    }
16452                    catch (Exception e) {
16453                            throw processException(e);
16454                    }
16455                    finally {
16456                            closeSession(session);
16457                    }
16458            }
16459    
16460            protected JournalArticle getByC_NotST_PrevAndNext(Session session,
16461                    JournalArticle journalArticle, long companyId, int status,
16462                    OrderByComparator orderByComparator, boolean previous) {
16463                    StringBundler query = null;
16464    
16465                    if (orderByComparator != null) {
16466                            query = new StringBundler(6 +
16467                                            (orderByComparator.getOrderByFields().length * 6));
16468                    }
16469                    else {
16470                            query = new StringBundler(3);
16471                    }
16472    
16473                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16474    
16475                    query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16476    
16477                    query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16478    
16479                    if (orderByComparator != null) {
16480                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16481    
16482                            if (orderByConditionFields.length > 0) {
16483                                    query.append(WHERE_AND);
16484                            }
16485    
16486                            for (int i = 0; i < orderByConditionFields.length; i++) {
16487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16488                                    query.append(orderByConditionFields[i]);
16489    
16490                                    if ((i + 1) < orderByConditionFields.length) {
16491                                            if (orderByComparator.isAscending() ^ previous) {
16492                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16493                                            }
16494                                            else {
16495                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16496                                            }
16497                                    }
16498                                    else {
16499                                            if (orderByComparator.isAscending() ^ previous) {
16500                                                    query.append(WHERE_GREATER_THAN);
16501                                            }
16502                                            else {
16503                                                    query.append(WHERE_LESSER_THAN);
16504                                            }
16505                                    }
16506                            }
16507    
16508                            query.append(ORDER_BY_CLAUSE);
16509    
16510                            String[] orderByFields = orderByComparator.getOrderByFields();
16511    
16512                            for (int i = 0; i < orderByFields.length; i++) {
16513                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16514                                    query.append(orderByFields[i]);
16515    
16516                                    if ((i + 1) < orderByFields.length) {
16517                                            if (orderByComparator.isAscending() ^ previous) {
16518                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16519                                            }
16520                                            else {
16521                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16522                                            }
16523                                    }
16524                                    else {
16525                                            if (orderByComparator.isAscending() ^ previous) {
16526                                                    query.append(ORDER_BY_ASC);
16527                                            }
16528                                            else {
16529                                                    query.append(ORDER_BY_DESC);
16530                                            }
16531                                    }
16532                            }
16533                    }
16534                    else {
16535                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16536                    }
16537    
16538                    String sql = query.toString();
16539    
16540                    Query q = session.createQuery(sql);
16541    
16542                    q.setFirstResult(0);
16543                    q.setMaxResults(2);
16544    
16545                    QueryPos qPos = QueryPos.getInstance(q);
16546    
16547                    qPos.add(companyId);
16548    
16549                    qPos.add(status);
16550    
16551                    if (orderByComparator != null) {
16552                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16553    
16554                            for (Object value : values) {
16555                                    qPos.add(value);
16556                            }
16557                    }
16558    
16559                    List<JournalArticle> list = q.list();
16560    
16561                    if (list.size() == 2) {
16562                            return list.get(1);
16563                    }
16564                    else {
16565                            return null;
16566                    }
16567            }
16568    
16569            /**
16570             * Removes all the journal articles where companyId = &#63; and status &ne; &#63; from the database.
16571             *
16572             * @param companyId the company ID
16573             * @param status the status
16574             * @throws SystemException if a system exception occurred
16575             */
16576            @Override
16577            public void removeByC_NotST(long companyId, int status)
16578                    throws SystemException {
16579                    for (JournalArticle journalArticle : findByC_NotST(companyId, status,
16580                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16581                            remove(journalArticle);
16582                    }
16583            }
16584    
16585            /**
16586             * Returns the number of journal articles where companyId = &#63; and status &ne; &#63;.
16587             *
16588             * @param companyId the company ID
16589             * @param status the status
16590             * @return the number of matching journal articles
16591             * @throws SystemException if a system exception occurred
16592             */
16593            @Override
16594            public int countByC_NotST(long companyId, int status)
16595                    throws SystemException {
16596                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST;
16597    
16598                    Object[] finderArgs = new Object[] { companyId, status };
16599    
16600                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16601                                    this);
16602    
16603                    if (count == null) {
16604                            StringBundler query = new StringBundler(3);
16605    
16606                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16607    
16608                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16609    
16610                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16611    
16612                            String sql = query.toString();
16613    
16614                            Session session = null;
16615    
16616                            try {
16617                                    session = openSession();
16618    
16619                                    Query q = session.createQuery(sql);
16620    
16621                                    QueryPos qPos = QueryPos.getInstance(q);
16622    
16623                                    qPos.add(companyId);
16624    
16625                                    qPos.add(status);
16626    
16627                                    count = (Long)q.uniqueResult();
16628    
16629                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16630                            }
16631                            catch (Exception e) {
16632                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16633    
16634                                    throw processException(e);
16635                            }
16636                            finally {
16637                                    closeSession(session);
16638                            }
16639                    }
16640    
16641                    return count.intValue();
16642            }
16643    
16644            private static final String _FINDER_COLUMN_C_NOTST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16645            private static final String _FINDER_COLUMN_C_NOTST_STATUS_2 = "journalArticle.status != ?";
16646            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16647                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16648                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16649                            "findByLtD_S",
16650                            new String[] {
16651                                    Date.class.getName(), Integer.class.getName(),
16652                                    
16653                            Integer.class.getName(), Integer.class.getName(),
16654                                    OrderByComparator.class.getName()
16655                            });
16656            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16657                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16658                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
16659                            new String[] { Date.class.getName(), Integer.class.getName() });
16660    
16661            /**
16662             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
16663             *
16664             * @param displayDate the display date
16665             * @param status the status
16666             * @return the matching journal articles
16667             * @throws SystemException if a system exception occurred
16668             */
16669            @Override
16670            public List<JournalArticle> findByLtD_S(Date displayDate, int status)
16671                    throws SystemException {
16672                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
16673                            QueryUtil.ALL_POS, null);
16674            }
16675    
16676            /**
16677             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
16678             *
16679             * <p>
16680             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16681             * </p>
16682             *
16683             * @param displayDate the display date
16684             * @param status the status
16685             * @param start the lower bound of the range of journal articles
16686             * @param end the upper bound of the range of journal articles (not inclusive)
16687             * @return the range of matching journal articles
16688             * @throws SystemException if a system exception occurred
16689             */
16690            @Override
16691            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
16692                    int start, int end) throws SystemException {
16693                    return findByLtD_S(displayDate, status, start, end, null);
16694            }
16695    
16696            /**
16697             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
16698             *
16699             * <p>
16700             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16701             * </p>
16702             *
16703             * @param displayDate the display date
16704             * @param status the status
16705             * @param start the lower bound of the range of journal articles
16706             * @param end the upper bound of the range of journal articles (not inclusive)
16707             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16708             * @return the ordered range of matching journal articles
16709             * @throws SystemException if a system exception occurred
16710             */
16711            @Override
16712            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
16713                    int start, int end, OrderByComparator orderByComparator)
16714                    throws SystemException {
16715                    boolean pagination = true;
16716                    FinderPath finderPath = null;
16717                    Object[] finderArgs = null;
16718    
16719                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
16720                    finderArgs = new Object[] {
16721                                    displayDate, status,
16722                                    
16723                                    start, end, orderByComparator
16724                            };
16725    
16726                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16727                                    finderArgs, this);
16728    
16729                    if ((list != null) && !list.isEmpty()) {
16730                            for (JournalArticle journalArticle : list) {
16731                                    if ((displayDate.getTime() <= journalArticle.getDisplayDate()
16732                                                                                                                                    .getTime()) ||
16733                                                    (status != journalArticle.getStatus())) {
16734                                            list = null;
16735    
16736                                            break;
16737                                    }
16738                            }
16739                    }
16740    
16741                    if (list == null) {
16742                            StringBundler query = null;
16743    
16744                            if (orderByComparator != null) {
16745                                    query = new StringBundler(4 +
16746                                                    (orderByComparator.getOrderByFields().length * 3));
16747                            }
16748                            else {
16749                                    query = new StringBundler(4);
16750                            }
16751    
16752                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16753    
16754                            boolean bindDisplayDate = false;
16755    
16756                            if (displayDate == null) {
16757                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
16758                            }
16759                            else {
16760                                    bindDisplayDate = true;
16761    
16762                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
16763                            }
16764    
16765                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
16766    
16767                            if (orderByComparator != null) {
16768                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16769                                            orderByComparator);
16770                            }
16771                            else
16772                             if (pagination) {
16773                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16774                            }
16775    
16776                            String sql = query.toString();
16777    
16778                            Session session = null;
16779    
16780                            try {
16781                                    session = openSession();
16782    
16783                                    Query q = session.createQuery(sql);
16784    
16785                                    QueryPos qPos = QueryPos.getInstance(q);
16786    
16787                                    if (bindDisplayDate) {
16788                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16789                                    }
16790    
16791                                    qPos.add(status);
16792    
16793                                    if (!pagination) {
16794                                            list = (List<JournalArticle>)QueryUtil.list(q,
16795                                                            getDialect(), start, end, false);
16796    
16797                                            Collections.sort(list);
16798    
16799                                            list = new UnmodifiableList<JournalArticle>(list);
16800                                    }
16801                                    else {
16802                                            list = (List<JournalArticle>)QueryUtil.list(q,
16803                                                            getDialect(), start, end);
16804                                    }
16805    
16806                                    cacheResult(list);
16807    
16808                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16809                            }
16810                            catch (Exception e) {
16811                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16812    
16813                                    throw processException(e);
16814                            }
16815                            finally {
16816                                    closeSession(session);
16817                            }
16818                    }
16819    
16820                    return list;
16821            }
16822    
16823            /**
16824             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16825             *
16826             * @param displayDate the display date
16827             * @param status the status
16828             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16829             * @return the first matching journal article
16830             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16831             * @throws SystemException if a system exception occurred
16832             */
16833            @Override
16834            public JournalArticle findByLtD_S_First(Date displayDate, int status,
16835                    OrderByComparator orderByComparator)
16836                    throws NoSuchArticleException, SystemException {
16837                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
16838                                    orderByComparator);
16839    
16840                    if (journalArticle != null) {
16841                            return journalArticle;
16842                    }
16843    
16844                    StringBundler msg = new StringBundler(6);
16845    
16846                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16847    
16848                    msg.append("displayDate=");
16849                    msg.append(displayDate);
16850    
16851                    msg.append(", status=");
16852                    msg.append(status);
16853    
16854                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16855    
16856                    throw new NoSuchArticleException(msg.toString());
16857            }
16858    
16859            /**
16860             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16861             *
16862             * @param displayDate the display date
16863             * @param status the status
16864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16865             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16866             * @throws SystemException if a system exception occurred
16867             */
16868            @Override
16869            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
16870                    OrderByComparator orderByComparator) throws SystemException {
16871                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
16872                                    orderByComparator);
16873    
16874                    if (!list.isEmpty()) {
16875                            return list.get(0);
16876                    }
16877    
16878                    return null;
16879            }
16880    
16881            /**
16882             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16883             *
16884             * @param displayDate the display date
16885             * @param status the status
16886             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16887             * @return the last matching journal article
16888             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16889             * @throws SystemException if a system exception occurred
16890             */
16891            @Override
16892            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
16893                    OrderByComparator orderByComparator)
16894                    throws NoSuchArticleException, SystemException {
16895                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
16896                                    orderByComparator);
16897    
16898                    if (journalArticle != null) {
16899                            return journalArticle;
16900                    }
16901    
16902                    StringBundler msg = new StringBundler(6);
16903    
16904                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16905    
16906                    msg.append("displayDate=");
16907                    msg.append(displayDate);
16908    
16909                    msg.append(", status=");
16910                    msg.append(status);
16911    
16912                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16913    
16914                    throw new NoSuchArticleException(msg.toString());
16915            }
16916    
16917            /**
16918             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16919             *
16920             * @param displayDate the display date
16921             * @param status the status
16922             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16923             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16924             * @throws SystemException if a system exception occurred
16925             */
16926            @Override
16927            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
16928                    OrderByComparator orderByComparator) throws SystemException {
16929                    int count = countByLtD_S(displayDate, status);
16930    
16931                    if (count == 0) {
16932                            return null;
16933                    }
16934    
16935                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
16936                                    count, orderByComparator);
16937    
16938                    if (!list.isEmpty()) {
16939                            return list.get(0);
16940                    }
16941    
16942                    return null;
16943            }
16944    
16945            /**
16946             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16947             *
16948             * @param id the primary key of the current journal article
16949             * @param displayDate the display date
16950             * @param status the status
16951             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16952             * @return the previous, current, and next journal article
16953             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16954             * @throws SystemException if a system exception occurred
16955             */
16956            @Override
16957            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
16958                    int status, OrderByComparator orderByComparator)
16959                    throws NoSuchArticleException, SystemException {
16960                    JournalArticle journalArticle = findByPrimaryKey(id);
16961    
16962                    Session session = null;
16963    
16964                    try {
16965                            session = openSession();
16966    
16967                            JournalArticle[] array = new JournalArticleImpl[3];
16968    
16969                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
16970                                            displayDate, status, orderByComparator, true);
16971    
16972                            array[1] = journalArticle;
16973    
16974                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
16975                                            displayDate, status, orderByComparator, false);
16976    
16977                            return array;
16978                    }
16979                    catch (Exception e) {
16980                            throw processException(e);
16981                    }
16982                    finally {
16983                            closeSession(session);
16984                    }
16985            }
16986    
16987            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
16988                    JournalArticle journalArticle, Date displayDate, int status,
16989                    OrderByComparator orderByComparator, boolean previous) {
16990                    StringBundler query = null;
16991    
16992                    if (orderByComparator != null) {
16993                            query = new StringBundler(6 +
16994                                            (orderByComparator.getOrderByFields().length * 6));
16995                    }
16996                    else {
16997                            query = new StringBundler(3);
16998                    }
16999    
17000                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17001    
17002                    boolean bindDisplayDate = false;
17003    
17004                    if (displayDate == null) {
17005                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17006                    }
17007                    else {
17008                            bindDisplayDate = true;
17009    
17010                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17011                    }
17012    
17013                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17014    
17015                    if (orderByComparator != null) {
17016                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17017    
17018                            if (orderByConditionFields.length > 0) {
17019                                    query.append(WHERE_AND);
17020                            }
17021    
17022                            for (int i = 0; i < orderByConditionFields.length; i++) {
17023                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17024                                    query.append(orderByConditionFields[i]);
17025    
17026                                    if ((i + 1) < orderByConditionFields.length) {
17027                                            if (orderByComparator.isAscending() ^ previous) {
17028                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17029                                            }
17030                                            else {
17031                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17032                                            }
17033                                    }
17034                                    else {
17035                                            if (orderByComparator.isAscending() ^ previous) {
17036                                                    query.append(WHERE_GREATER_THAN);
17037                                            }
17038                                            else {
17039                                                    query.append(WHERE_LESSER_THAN);
17040                                            }
17041                                    }
17042                            }
17043    
17044                            query.append(ORDER_BY_CLAUSE);
17045    
17046                            String[] orderByFields = orderByComparator.getOrderByFields();
17047    
17048                            for (int i = 0; i < orderByFields.length; i++) {
17049                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17050                                    query.append(orderByFields[i]);
17051    
17052                                    if ((i + 1) < orderByFields.length) {
17053                                            if (orderByComparator.isAscending() ^ previous) {
17054                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17055                                            }
17056                                            else {
17057                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17058                                            }
17059                                    }
17060                                    else {
17061                                            if (orderByComparator.isAscending() ^ previous) {
17062                                                    query.append(ORDER_BY_ASC);
17063                                            }
17064                                            else {
17065                                                    query.append(ORDER_BY_DESC);
17066                                            }
17067                                    }
17068                            }
17069                    }
17070                    else {
17071                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17072                    }
17073    
17074                    String sql = query.toString();
17075    
17076                    Query q = session.createQuery(sql);
17077    
17078                    q.setFirstResult(0);
17079                    q.setMaxResults(2);
17080    
17081                    QueryPos qPos = QueryPos.getInstance(q);
17082    
17083                    if (bindDisplayDate) {
17084                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17085                    }
17086    
17087                    qPos.add(status);
17088    
17089                    if (orderByComparator != null) {
17090                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17091    
17092                            for (Object value : values) {
17093                                    qPos.add(value);
17094                            }
17095                    }
17096    
17097                    List<JournalArticle> list = q.list();
17098    
17099                    if (list.size() == 2) {
17100                            return list.get(1);
17101                    }
17102                    else {
17103                            return null;
17104                    }
17105            }
17106    
17107            /**
17108             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
17109             *
17110             * @param displayDate the display date
17111             * @param status the status
17112             * @throws SystemException if a system exception occurred
17113             */
17114            @Override
17115            public void removeByLtD_S(Date displayDate, int status)
17116                    throws SystemException {
17117                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
17118                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17119                            remove(journalArticle);
17120                    }
17121            }
17122    
17123            /**
17124             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
17125             *
17126             * @param displayDate the display date
17127             * @param status the status
17128             * @return the number of matching journal articles
17129             * @throws SystemException if a system exception occurred
17130             */
17131            @Override
17132            public int countByLtD_S(Date displayDate, int status)
17133                    throws SystemException {
17134                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
17135    
17136                    Object[] finderArgs = new Object[] { displayDate, status };
17137    
17138                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17139                                    this);
17140    
17141                    if (count == null) {
17142                            StringBundler query = new StringBundler(3);
17143    
17144                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17145    
17146                            boolean bindDisplayDate = false;
17147    
17148                            if (displayDate == null) {
17149                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17150                            }
17151                            else {
17152                                    bindDisplayDate = true;
17153    
17154                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17155                            }
17156    
17157                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17158    
17159                            String sql = query.toString();
17160    
17161                            Session session = null;
17162    
17163                            try {
17164                                    session = openSession();
17165    
17166                                    Query q = session.createQuery(sql);
17167    
17168                                    QueryPos qPos = QueryPos.getInstance(q);
17169    
17170                                    if (bindDisplayDate) {
17171                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17172                                    }
17173    
17174                                    qPos.add(status);
17175    
17176                                    count = (Long)q.uniqueResult();
17177    
17178                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17179                            }
17180                            catch (Exception e) {
17181                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17182    
17183                                    throw processException(e);
17184                            }
17185                            finally {
17186                                    closeSession(session);
17187                            }
17188                    }
17189    
17190                    return count.intValue();
17191            }
17192    
17193            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
17194            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
17195            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
17196            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17197                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17198                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17199                            "findByR_I_S",
17200                            new String[] {
17201                                    Long.class.getName(), Boolean.class.getName(),
17202                                    Integer.class.getName(),
17203                                    
17204                            Integer.class.getName(), Integer.class.getName(),
17205                                    OrderByComparator.class.getName()
17206                            });
17207            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17208                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17209                            JournalArticleImpl.class,
17210                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
17211                            new String[] {
17212                                    Long.class.getName(), Boolean.class.getName(),
17213                                    Integer.class.getName()
17214                            },
17215                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
17216                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
17217                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
17218                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17219                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17220            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17221                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17222                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
17223                            new String[] {
17224                                    Long.class.getName(), Boolean.class.getName(),
17225                                    Integer.class.getName()
17226                            });
17227            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17228                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17229                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
17230                            new String[] {
17231                                    Long.class.getName(), Boolean.class.getName(),
17232                                    Integer.class.getName()
17233                            });
17234    
17235            /**
17236             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17237             *
17238             * @param resourcePrimKey the resource prim key
17239             * @param indexable the indexable
17240             * @param status the status
17241             * @return the matching journal articles
17242             * @throws SystemException if a system exception occurred
17243             */
17244            @Override
17245            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17246                    boolean indexable, int status) throws SystemException {
17247                    return findByR_I_S(resourcePrimKey, indexable, status,
17248                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17249            }
17250    
17251            /**
17252             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17253             *
17254             * <p>
17255             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17256             * </p>
17257             *
17258             * @param resourcePrimKey the resource prim key
17259             * @param indexable the indexable
17260             * @param status the status
17261             * @param start the lower bound of the range of journal articles
17262             * @param end the upper bound of the range of journal articles (not inclusive)
17263             * @return the range of matching journal articles
17264             * @throws SystemException if a system exception occurred
17265             */
17266            @Override
17267            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17268                    boolean indexable, int status, int start, int end)
17269                    throws SystemException {
17270                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
17271            }
17272    
17273            /**
17274             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17275             *
17276             * <p>
17277             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17278             * </p>
17279             *
17280             * @param resourcePrimKey the resource prim key
17281             * @param indexable the indexable
17282             * @param status the status
17283             * @param start the lower bound of the range of journal articles
17284             * @param end the upper bound of the range of journal articles (not inclusive)
17285             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17286             * @return the ordered range of matching journal articles
17287             * @throws SystemException if a system exception occurred
17288             */
17289            @Override
17290            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17291                    boolean indexable, int status, int start, int end,
17292                    OrderByComparator orderByComparator) throws SystemException {
17293                    boolean pagination = true;
17294                    FinderPath finderPath = null;
17295                    Object[] finderArgs = null;
17296    
17297                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17298                                    (orderByComparator == null)) {
17299                            pagination = false;
17300                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
17301                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
17302                    }
17303                    else {
17304                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
17305                            finderArgs = new Object[] {
17306                                            resourcePrimKey, indexable, status,
17307                                            
17308                                            start, end, orderByComparator
17309                                    };
17310                    }
17311    
17312                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17313                                    finderArgs, this);
17314    
17315                    if ((list != null) && !list.isEmpty()) {
17316                            for (JournalArticle journalArticle : list) {
17317                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
17318                                                    (indexable != journalArticle.getIndexable()) ||
17319                                                    (status != journalArticle.getStatus())) {
17320                                            list = null;
17321    
17322                                            break;
17323                                    }
17324                            }
17325                    }
17326    
17327                    if (list == null) {
17328                            StringBundler query = null;
17329    
17330                            if (orderByComparator != null) {
17331                                    query = new StringBundler(5 +
17332                                                    (orderByComparator.getOrderByFields().length * 3));
17333                            }
17334                            else {
17335                                    query = new StringBundler(5);
17336                            }
17337    
17338                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17339    
17340                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17341    
17342                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17343    
17344                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17345    
17346                            if (orderByComparator != null) {
17347                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17348                                            orderByComparator);
17349                            }
17350                            else
17351                             if (pagination) {
17352                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17353                            }
17354    
17355                            String sql = query.toString();
17356    
17357                            Session session = null;
17358    
17359                            try {
17360                                    session = openSession();
17361    
17362                                    Query q = session.createQuery(sql);
17363    
17364                                    QueryPos qPos = QueryPos.getInstance(q);
17365    
17366                                    qPos.add(resourcePrimKey);
17367    
17368                                    qPos.add(indexable);
17369    
17370                                    qPos.add(status);
17371    
17372                                    if (!pagination) {
17373                                            list = (List<JournalArticle>)QueryUtil.list(q,
17374                                                            getDialect(), start, end, false);
17375    
17376                                            Collections.sort(list);
17377    
17378                                            list = new UnmodifiableList<JournalArticle>(list);
17379                                    }
17380                                    else {
17381                                            list = (List<JournalArticle>)QueryUtil.list(q,
17382                                                            getDialect(), start, end);
17383                                    }
17384    
17385                                    cacheResult(list);
17386    
17387                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17388                            }
17389                            catch (Exception e) {
17390                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17391    
17392                                    throw processException(e);
17393                            }
17394                            finally {
17395                                    closeSession(session);
17396                            }
17397                    }
17398    
17399                    return list;
17400            }
17401    
17402            /**
17403             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17404             *
17405             * @param resourcePrimKey the resource prim key
17406             * @param indexable the indexable
17407             * @param status the status
17408             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17409             * @return the first matching journal article
17410             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17411             * @throws SystemException if a system exception occurred
17412             */
17413            @Override
17414            public JournalArticle findByR_I_S_First(long resourcePrimKey,
17415                    boolean indexable, int status, OrderByComparator orderByComparator)
17416                    throws NoSuchArticleException, SystemException {
17417                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
17418                                    indexable, status, orderByComparator);
17419    
17420                    if (journalArticle != null) {
17421                            return journalArticle;
17422                    }
17423    
17424                    StringBundler msg = new StringBundler(8);
17425    
17426                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17427    
17428                    msg.append("resourcePrimKey=");
17429                    msg.append(resourcePrimKey);
17430    
17431                    msg.append(", indexable=");
17432                    msg.append(indexable);
17433    
17434                    msg.append(", status=");
17435                    msg.append(status);
17436    
17437                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17438    
17439                    throw new NoSuchArticleException(msg.toString());
17440            }
17441    
17442            /**
17443             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17444             *
17445             * @param resourcePrimKey the resource prim key
17446             * @param indexable the indexable
17447             * @param status the status
17448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17449             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17450             * @throws SystemException if a system exception occurred
17451             */
17452            @Override
17453            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
17454                    boolean indexable, int status, OrderByComparator orderByComparator)
17455                    throws SystemException {
17456                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
17457                                    status, 0, 1, orderByComparator);
17458    
17459                    if (!list.isEmpty()) {
17460                            return list.get(0);
17461                    }
17462    
17463                    return null;
17464            }
17465    
17466            /**
17467             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17468             *
17469             * @param resourcePrimKey the resource prim key
17470             * @param indexable the indexable
17471             * @param status the status
17472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17473             * @return the last matching journal article
17474             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17475             * @throws SystemException if a system exception occurred
17476             */
17477            @Override
17478            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
17479                    boolean indexable, int status, OrderByComparator orderByComparator)
17480                    throws NoSuchArticleException, SystemException {
17481                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
17482                                    indexable, status, orderByComparator);
17483    
17484                    if (journalArticle != null) {
17485                            return journalArticle;
17486                    }
17487    
17488                    StringBundler msg = new StringBundler(8);
17489    
17490                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17491    
17492                    msg.append("resourcePrimKey=");
17493                    msg.append(resourcePrimKey);
17494    
17495                    msg.append(", indexable=");
17496                    msg.append(indexable);
17497    
17498                    msg.append(", status=");
17499                    msg.append(status);
17500    
17501                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17502    
17503                    throw new NoSuchArticleException(msg.toString());
17504            }
17505    
17506            /**
17507             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17508             *
17509             * @param resourcePrimKey the resource prim key
17510             * @param indexable the indexable
17511             * @param status the status
17512             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17513             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17514             * @throws SystemException if a system exception occurred
17515             */
17516            @Override
17517            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
17518                    boolean indexable, int status, OrderByComparator orderByComparator)
17519                    throws SystemException {
17520                    int count = countByR_I_S(resourcePrimKey, indexable, status);
17521    
17522                    if (count == 0) {
17523                            return null;
17524                    }
17525    
17526                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
17527                                    status, count - 1, count, orderByComparator);
17528    
17529                    if (!list.isEmpty()) {
17530                            return list.get(0);
17531                    }
17532    
17533                    return null;
17534            }
17535    
17536            /**
17537             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17538             *
17539             * @param id the primary key of the current journal article
17540             * @param resourcePrimKey the resource prim key
17541             * @param indexable the indexable
17542             * @param status the status
17543             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17544             * @return the previous, current, and next journal article
17545             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17546             * @throws SystemException if a system exception occurred
17547             */
17548            @Override
17549            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
17550                    long resourcePrimKey, boolean indexable, int status,
17551                    OrderByComparator orderByComparator)
17552                    throws NoSuchArticleException, SystemException {
17553                    JournalArticle journalArticle = findByPrimaryKey(id);
17554    
17555                    Session session = null;
17556    
17557                    try {
17558                            session = openSession();
17559    
17560                            JournalArticle[] array = new JournalArticleImpl[3];
17561    
17562                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
17563                                            resourcePrimKey, indexable, status, orderByComparator, true);
17564    
17565                            array[1] = journalArticle;
17566    
17567                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
17568                                            resourcePrimKey, indexable, status, orderByComparator, false);
17569    
17570                            return array;
17571                    }
17572                    catch (Exception e) {
17573                            throw processException(e);
17574                    }
17575                    finally {
17576                            closeSession(session);
17577                    }
17578            }
17579    
17580            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
17581                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
17582                    int status, OrderByComparator orderByComparator, boolean previous) {
17583                    StringBundler query = null;
17584    
17585                    if (orderByComparator != null) {
17586                            query = new StringBundler(6 +
17587                                            (orderByComparator.getOrderByFields().length * 6));
17588                    }
17589                    else {
17590                            query = new StringBundler(3);
17591                    }
17592    
17593                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17594    
17595                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17596    
17597                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17598    
17599                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17600    
17601                    if (orderByComparator != null) {
17602                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17603    
17604                            if (orderByConditionFields.length > 0) {
17605                                    query.append(WHERE_AND);
17606                            }
17607    
17608                            for (int i = 0; i < orderByConditionFields.length; i++) {
17609                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17610                                    query.append(orderByConditionFields[i]);
17611    
17612                                    if ((i + 1) < orderByConditionFields.length) {
17613                                            if (orderByComparator.isAscending() ^ previous) {
17614                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17615                                            }
17616                                            else {
17617                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17618                                            }
17619                                    }
17620                                    else {
17621                                            if (orderByComparator.isAscending() ^ previous) {
17622                                                    query.append(WHERE_GREATER_THAN);
17623                                            }
17624                                            else {
17625                                                    query.append(WHERE_LESSER_THAN);
17626                                            }
17627                                    }
17628                            }
17629    
17630                            query.append(ORDER_BY_CLAUSE);
17631    
17632                            String[] orderByFields = orderByComparator.getOrderByFields();
17633    
17634                            for (int i = 0; i < orderByFields.length; i++) {
17635                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17636                                    query.append(orderByFields[i]);
17637    
17638                                    if ((i + 1) < orderByFields.length) {
17639                                            if (orderByComparator.isAscending() ^ previous) {
17640                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17641                                            }
17642                                            else {
17643                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17644                                            }
17645                                    }
17646                                    else {
17647                                            if (orderByComparator.isAscending() ^ previous) {
17648                                                    query.append(ORDER_BY_ASC);
17649                                            }
17650                                            else {
17651                                                    query.append(ORDER_BY_DESC);
17652                                            }
17653                                    }
17654                            }
17655                    }
17656                    else {
17657                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17658                    }
17659    
17660                    String sql = query.toString();
17661    
17662                    Query q = session.createQuery(sql);
17663    
17664                    q.setFirstResult(0);
17665                    q.setMaxResults(2);
17666    
17667                    QueryPos qPos = QueryPos.getInstance(q);
17668    
17669                    qPos.add(resourcePrimKey);
17670    
17671                    qPos.add(indexable);
17672    
17673                    qPos.add(status);
17674    
17675                    if (orderByComparator != null) {
17676                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17677    
17678                            for (Object value : values) {
17679                                    qPos.add(value);
17680                            }
17681                    }
17682    
17683                    List<JournalArticle> list = q.list();
17684    
17685                    if (list.size() == 2) {
17686                            return list.get(1);
17687                    }
17688                    else {
17689                            return null;
17690                    }
17691            }
17692    
17693            /**
17694             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17695             *
17696             * <p>
17697             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17698             * </p>
17699             *
17700             * @param resourcePrimKey the resource prim key
17701             * @param indexable the indexable
17702             * @param statuses the statuses
17703             * @return the matching journal articles
17704             * @throws SystemException if a system exception occurred
17705             */
17706            @Override
17707            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17708                    boolean indexable, int[] statuses) throws SystemException {
17709                    return findByR_I_S(resourcePrimKey, indexable, statuses,
17710                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17711            }
17712    
17713            /**
17714             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17715             *
17716             * <p>
17717             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17718             * </p>
17719             *
17720             * @param resourcePrimKey the resource prim key
17721             * @param indexable the indexable
17722             * @param statuses the statuses
17723             * @param start the lower bound of the range of journal articles
17724             * @param end the upper bound of the range of journal articles (not inclusive)
17725             * @return the range of matching journal articles
17726             * @throws SystemException if a system exception occurred
17727             */
17728            @Override
17729            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17730                    boolean indexable, int[] statuses, int start, int end)
17731                    throws SystemException {
17732                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
17733                            null);
17734            }
17735    
17736            /**
17737             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17738             *
17739             * <p>
17740             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17741             * </p>
17742             *
17743             * @param resourcePrimKey the resource prim key
17744             * @param indexable the indexable
17745             * @param statuses the statuses
17746             * @param start the lower bound of the range of journal articles
17747             * @param end the upper bound of the range of journal articles (not inclusive)
17748             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17749             * @return the ordered range of matching journal articles
17750             * @throws SystemException if a system exception occurred
17751             */
17752            @Override
17753            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17754                    boolean indexable, int[] statuses, int start, int end,
17755                    OrderByComparator orderByComparator) throws SystemException {
17756                    if ((statuses != null) && (statuses.length == 1)) {
17757                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
17758                                    end, orderByComparator);
17759                    }
17760    
17761                    boolean pagination = true;
17762                    Object[] finderArgs = null;
17763    
17764                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17765                                    (orderByComparator == null)) {
17766                            pagination = false;
17767                            finderArgs = new Object[] {
17768                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
17769                                    };
17770                    }
17771                    else {
17772                            finderArgs = new Object[] {
17773                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
17774                                            
17775                                            start, end, orderByComparator
17776                                    };
17777                    }
17778    
17779                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
17780                                    finderArgs, this);
17781    
17782                    if ((list != null) && !list.isEmpty()) {
17783                            for (JournalArticle journalArticle : list) {
17784                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
17785                                                    (indexable != journalArticle.getIndexable()) ||
17786                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
17787                                            list = null;
17788    
17789                                            break;
17790                                    }
17791                            }
17792                    }
17793    
17794                    if (list == null) {
17795                            StringBundler query = new StringBundler();
17796    
17797                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17798    
17799                            boolean conjunctionable = false;
17800    
17801                            if (conjunctionable) {
17802                                    query.append(WHERE_AND);
17803                            }
17804    
17805                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
17806    
17807                            conjunctionable = true;
17808    
17809                            if (conjunctionable) {
17810                                    query.append(WHERE_AND);
17811                            }
17812    
17813                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
17814    
17815                            conjunctionable = true;
17816    
17817                            if ((statuses == null) || (statuses.length > 0)) {
17818                                    if (conjunctionable) {
17819                                            query.append(WHERE_AND);
17820                                    }
17821    
17822                                    query.append(StringPool.OPEN_PARENTHESIS);
17823    
17824                                    for (int i = 0; i < statuses.length; i++) {
17825                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
17826    
17827                                            if ((i + 1) < statuses.length) {
17828                                                    query.append(WHERE_OR);
17829                                            }
17830                                    }
17831    
17832                                    query.append(StringPool.CLOSE_PARENTHESIS);
17833    
17834                                    conjunctionable = true;
17835                            }
17836    
17837                            if (orderByComparator != null) {
17838                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17839                                            orderByComparator);
17840                            }
17841                            else
17842                             if (pagination) {
17843                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17844                            }
17845    
17846                            String sql = query.toString();
17847    
17848                            Session session = null;
17849    
17850                            try {
17851                                    session = openSession();
17852    
17853                                    Query q = session.createQuery(sql);
17854    
17855                                    QueryPos qPos = QueryPos.getInstance(q);
17856    
17857                                    qPos.add(resourcePrimKey);
17858    
17859                                    qPos.add(indexable);
17860    
17861                                    if (statuses != null) {
17862                                            qPos.add(statuses);
17863                                    }
17864    
17865                                    if (!pagination) {
17866                                            list = (List<JournalArticle>)QueryUtil.list(q,
17867                                                            getDialect(), start, end, false);
17868    
17869                                            Collections.sort(list);
17870    
17871                                            list = new UnmodifiableList<JournalArticle>(list);
17872                                    }
17873                                    else {
17874                                            list = (List<JournalArticle>)QueryUtil.list(q,
17875                                                            getDialect(), start, end);
17876                                    }
17877    
17878                                    cacheResult(list);
17879    
17880                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
17881                                            finderArgs, list);
17882                            }
17883                            catch (Exception e) {
17884                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
17885                                            finderArgs);
17886    
17887                                    throw processException(e);
17888                            }
17889                            finally {
17890                                    closeSession(session);
17891                            }
17892                    }
17893    
17894                    return list;
17895            }
17896    
17897            /**
17898             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
17899             *
17900             * @param resourcePrimKey the resource prim key
17901             * @param indexable the indexable
17902             * @param status the status
17903             * @throws SystemException if a system exception occurred
17904             */
17905            @Override
17906            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
17907                    int status) throws SystemException {
17908                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
17909                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17910                            remove(journalArticle);
17911                    }
17912            }
17913    
17914            /**
17915             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17916             *
17917             * @param resourcePrimKey the resource prim key
17918             * @param indexable the indexable
17919             * @param status the status
17920             * @return the number of matching journal articles
17921             * @throws SystemException if a system exception occurred
17922             */
17923            @Override
17924            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status)
17925                    throws SystemException {
17926                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
17927    
17928                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
17929    
17930                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17931                                    this);
17932    
17933                    if (count == null) {
17934                            StringBundler query = new StringBundler(4);
17935    
17936                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17937    
17938                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17939    
17940                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17941    
17942                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17943    
17944                            String sql = query.toString();
17945    
17946                            Session session = null;
17947    
17948                            try {
17949                                    session = openSession();
17950    
17951                                    Query q = session.createQuery(sql);
17952    
17953                                    QueryPos qPos = QueryPos.getInstance(q);
17954    
17955                                    qPos.add(resourcePrimKey);
17956    
17957                                    qPos.add(indexable);
17958    
17959                                    qPos.add(status);
17960    
17961                                    count = (Long)q.uniqueResult();
17962    
17963                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17964                            }
17965                            catch (Exception e) {
17966                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17967    
17968                                    throw processException(e);
17969                            }
17970                            finally {
17971                                    closeSession(session);
17972                            }
17973                    }
17974    
17975                    return count.intValue();
17976            }
17977    
17978            /**
17979             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17980             *
17981             * @param resourcePrimKey the resource prim key
17982             * @param indexable the indexable
17983             * @param statuses the statuses
17984             * @return the number of matching journal articles
17985             * @throws SystemException if a system exception occurred
17986             */
17987            @Override
17988            public int countByR_I_S(long resourcePrimKey, boolean indexable,
17989                    int[] statuses) throws SystemException {
17990                    Object[] finderArgs = new Object[] {
17991                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
17992                            };
17993    
17994                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
17995                                    finderArgs, this);
17996    
17997                    if (count == null) {
17998                            StringBundler query = new StringBundler();
17999    
18000                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18001    
18002                            boolean conjunctionable = false;
18003    
18004                            if (conjunctionable) {
18005                                    query.append(WHERE_AND);
18006                            }
18007    
18008                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
18009    
18010                            conjunctionable = true;
18011    
18012                            if (conjunctionable) {
18013                                    query.append(WHERE_AND);
18014                            }
18015    
18016                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
18017    
18018                            conjunctionable = true;
18019    
18020                            if ((statuses == null) || (statuses.length > 0)) {
18021                                    if (conjunctionable) {
18022                                            query.append(WHERE_AND);
18023                                    }
18024    
18025                                    query.append(StringPool.OPEN_PARENTHESIS);
18026    
18027                                    for (int i = 0; i < statuses.length; i++) {
18028                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
18029    
18030                                            if ((i + 1) < statuses.length) {
18031                                                    query.append(WHERE_OR);
18032                                            }
18033                                    }
18034    
18035                                    query.append(StringPool.CLOSE_PARENTHESIS);
18036    
18037                                    conjunctionable = true;
18038                            }
18039    
18040                            String sql = query.toString();
18041    
18042                            Session session = null;
18043    
18044                            try {
18045                                    session = openSession();
18046    
18047                                    Query q = session.createQuery(sql);
18048    
18049                                    QueryPos qPos = QueryPos.getInstance(q);
18050    
18051                                    qPos.add(resourcePrimKey);
18052    
18053                                    qPos.add(indexable);
18054    
18055                                    if (statuses != null) {
18056                                            qPos.add(statuses);
18057                                    }
18058    
18059                                    count = (Long)q.uniqueResult();
18060    
18061                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18062                                            finderArgs, count);
18063                            }
18064                            catch (Exception e) {
18065                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18066                                            finderArgs);
18067    
18068                                    throw processException(e);
18069                            }
18070                            finally {
18071                                    closeSession(session);
18072                            }
18073                    }
18074    
18075                    return count.intValue();
18076            }
18077    
18078            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
18079            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5 = "(" +
18080                    removeConjunction(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2) + ")";
18081            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
18082            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_5 = "(" +
18083                    removeConjunction(_FINDER_COLUMN_R_I_S_INDEXABLE_2) + ")";
18084            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
18085            private static final String _FINDER_COLUMN_R_I_S_STATUS_5 = "(" +
18086                    removeConjunction(_FINDER_COLUMN_R_I_S_STATUS_2) + ")";
18087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18088                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18089                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18090                            "findByG_U_C",
18091                            new String[] {
18092                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
18093                                    
18094                            Integer.class.getName(), Integer.class.getName(),
18095                                    OrderByComparator.class.getName()
18096                            });
18097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18098                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18099                            JournalArticleImpl.class,
18100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
18101                            new String[] {
18102                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18103                            },
18104                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18105                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
18106                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18107                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18108                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18109            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18110                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
18112                            new String[] {
18113                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18114                            });
18115    
18116            /**
18117             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18118             *
18119             * @param groupId the group ID
18120             * @param userId the user ID
18121             * @param classNameId the class name ID
18122             * @return the matching journal articles
18123             * @throws SystemException if a system exception occurred
18124             */
18125            @Override
18126            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18127                    long classNameId) throws SystemException {
18128                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
18129                            QueryUtil.ALL_POS, null);
18130            }
18131    
18132            /**
18133             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18134             *
18135             * <p>
18136             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18137             * </p>
18138             *
18139             * @param groupId the group ID
18140             * @param userId the user ID
18141             * @param classNameId the class name ID
18142             * @param start the lower bound of the range of journal articles
18143             * @param end the upper bound of the range of journal articles (not inclusive)
18144             * @return the range of matching journal articles
18145             * @throws SystemException if a system exception occurred
18146             */
18147            @Override
18148            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18149                    long classNameId, int start, int end) throws SystemException {
18150                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
18151            }
18152    
18153            /**
18154             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18155             *
18156             * <p>
18157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18158             * </p>
18159             *
18160             * @param groupId the group ID
18161             * @param userId the user ID
18162             * @param classNameId the class name ID
18163             * @param start the lower bound of the range of journal articles
18164             * @param end the upper bound of the range of journal articles (not inclusive)
18165             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18166             * @return the ordered range of matching journal articles
18167             * @throws SystemException if a system exception occurred
18168             */
18169            @Override
18170            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18171                    long classNameId, int start, int end,
18172                    OrderByComparator orderByComparator) throws SystemException {
18173                    boolean pagination = true;
18174                    FinderPath finderPath = null;
18175                    Object[] finderArgs = null;
18176    
18177                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18178                                    (orderByComparator == null)) {
18179                            pagination = false;
18180                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
18181                            finderArgs = new Object[] { groupId, userId, classNameId };
18182                    }
18183                    else {
18184                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
18185                            finderArgs = new Object[] {
18186                                            groupId, userId, classNameId,
18187                                            
18188                                            start, end, orderByComparator
18189                                    };
18190                    }
18191    
18192                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18193                                    finderArgs, this);
18194    
18195                    if ((list != null) && !list.isEmpty()) {
18196                            for (JournalArticle journalArticle : list) {
18197                                    if ((groupId != journalArticle.getGroupId()) ||
18198                                                    (userId != journalArticle.getUserId()) ||
18199                                                    (classNameId != journalArticle.getClassNameId())) {
18200                                            list = null;
18201    
18202                                            break;
18203                                    }
18204                            }
18205                    }
18206    
18207                    if (list == null) {
18208                            StringBundler query = null;
18209    
18210                            if (orderByComparator != null) {
18211                                    query = new StringBundler(5 +
18212                                                    (orderByComparator.getOrderByFields().length * 3));
18213                            }
18214                            else {
18215                                    query = new StringBundler(5);
18216                            }
18217    
18218                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18219    
18220                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18221    
18222                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18223    
18224                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18225    
18226                            if (orderByComparator != null) {
18227                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18228                                            orderByComparator);
18229                            }
18230                            else
18231                             if (pagination) {
18232                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18233                            }
18234    
18235                            String sql = query.toString();
18236    
18237                            Session session = null;
18238    
18239                            try {
18240                                    session = openSession();
18241    
18242                                    Query q = session.createQuery(sql);
18243    
18244                                    QueryPos qPos = QueryPos.getInstance(q);
18245    
18246                                    qPos.add(groupId);
18247    
18248                                    qPos.add(userId);
18249    
18250                                    qPos.add(classNameId);
18251    
18252                                    if (!pagination) {
18253                                            list = (List<JournalArticle>)QueryUtil.list(q,
18254                                                            getDialect(), start, end, false);
18255    
18256                                            Collections.sort(list);
18257    
18258                                            list = new UnmodifiableList<JournalArticle>(list);
18259                                    }
18260                                    else {
18261                                            list = (List<JournalArticle>)QueryUtil.list(q,
18262                                                            getDialect(), start, end);
18263                                    }
18264    
18265                                    cacheResult(list);
18266    
18267                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18268                            }
18269                            catch (Exception e) {
18270                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18271    
18272                                    throw processException(e);
18273                            }
18274                            finally {
18275                                    closeSession(session);
18276                            }
18277                    }
18278    
18279                    return list;
18280            }
18281    
18282            /**
18283             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18284             *
18285             * @param groupId the group ID
18286             * @param userId the user ID
18287             * @param classNameId the class name ID
18288             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18289             * @return the first matching journal article
18290             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18291             * @throws SystemException if a system exception occurred
18292             */
18293            @Override
18294            public JournalArticle findByG_U_C_First(long groupId, long userId,
18295                    long classNameId, OrderByComparator orderByComparator)
18296                    throws NoSuchArticleException, SystemException {
18297                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
18298                                    classNameId, orderByComparator);
18299    
18300                    if (journalArticle != null) {
18301                            return journalArticle;
18302                    }
18303    
18304                    StringBundler msg = new StringBundler(8);
18305    
18306                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18307    
18308                    msg.append("groupId=");
18309                    msg.append(groupId);
18310    
18311                    msg.append(", userId=");
18312                    msg.append(userId);
18313    
18314                    msg.append(", classNameId=");
18315                    msg.append(classNameId);
18316    
18317                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18318    
18319                    throw new NoSuchArticleException(msg.toString());
18320            }
18321    
18322            /**
18323             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18324             *
18325             * @param groupId the group ID
18326             * @param userId the user ID
18327             * @param classNameId the class name ID
18328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18329             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18330             * @throws SystemException if a system exception occurred
18331             */
18332            @Override
18333            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
18334                    long classNameId, OrderByComparator orderByComparator)
18335                    throws SystemException {
18336                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
18337                                    0, 1, orderByComparator);
18338    
18339                    if (!list.isEmpty()) {
18340                            return list.get(0);
18341                    }
18342    
18343                    return null;
18344            }
18345    
18346            /**
18347             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18348             *
18349             * @param groupId the group ID
18350             * @param userId the user ID
18351             * @param classNameId the class name ID
18352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18353             * @return the last matching journal article
18354             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18355             * @throws SystemException if a system exception occurred
18356             */
18357            @Override
18358            public JournalArticle findByG_U_C_Last(long groupId, long userId,
18359                    long classNameId, OrderByComparator orderByComparator)
18360                    throws NoSuchArticleException, SystemException {
18361                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
18362                                    classNameId, orderByComparator);
18363    
18364                    if (journalArticle != null) {
18365                            return journalArticle;
18366                    }
18367    
18368                    StringBundler msg = new StringBundler(8);
18369    
18370                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18371    
18372                    msg.append("groupId=");
18373                    msg.append(groupId);
18374    
18375                    msg.append(", userId=");
18376                    msg.append(userId);
18377    
18378                    msg.append(", classNameId=");
18379                    msg.append(classNameId);
18380    
18381                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18382    
18383                    throw new NoSuchArticleException(msg.toString());
18384            }
18385    
18386            /**
18387             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18388             *
18389             * @param groupId the group ID
18390             * @param userId the user ID
18391             * @param classNameId the class name ID
18392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18393             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18394             * @throws SystemException if a system exception occurred
18395             */
18396            @Override
18397            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
18398                    long classNameId, OrderByComparator orderByComparator)
18399                    throws SystemException {
18400                    int count = countByG_U_C(groupId, userId, classNameId);
18401    
18402                    if (count == 0) {
18403                            return null;
18404                    }
18405    
18406                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
18407                                    count - 1, count, orderByComparator);
18408    
18409                    if (!list.isEmpty()) {
18410                            return list.get(0);
18411                    }
18412    
18413                    return null;
18414            }
18415    
18416            /**
18417             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18418             *
18419             * @param id the primary key of the current journal article
18420             * @param groupId the group ID
18421             * @param userId the user ID
18422             * @param classNameId the class name ID
18423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18424             * @return the previous, current, and next journal article
18425             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18426             * @throws SystemException if a system exception occurred
18427             */
18428            @Override
18429            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
18430                    long userId, long classNameId, OrderByComparator orderByComparator)
18431                    throws NoSuchArticleException, SystemException {
18432                    JournalArticle journalArticle = findByPrimaryKey(id);
18433    
18434                    Session session = null;
18435    
18436                    try {
18437                            session = openSession();
18438    
18439                            JournalArticle[] array = new JournalArticleImpl[3];
18440    
18441                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
18442                                            userId, classNameId, orderByComparator, true);
18443    
18444                            array[1] = journalArticle;
18445    
18446                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
18447                                            userId, classNameId, orderByComparator, false);
18448    
18449                            return array;
18450                    }
18451                    catch (Exception e) {
18452                            throw processException(e);
18453                    }
18454                    finally {
18455                            closeSession(session);
18456                    }
18457            }
18458    
18459            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
18460                    JournalArticle journalArticle, long groupId, long userId,
18461                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
18462                    StringBundler query = null;
18463    
18464                    if (orderByComparator != null) {
18465                            query = new StringBundler(6 +
18466                                            (orderByComparator.getOrderByFields().length * 6));
18467                    }
18468                    else {
18469                            query = new StringBundler(3);
18470                    }
18471    
18472                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18473    
18474                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18475    
18476                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18477    
18478                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18479    
18480                    if (orderByComparator != null) {
18481                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18482    
18483                            if (orderByConditionFields.length > 0) {
18484                                    query.append(WHERE_AND);
18485                            }
18486    
18487                            for (int i = 0; i < orderByConditionFields.length; i++) {
18488                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18489                                    query.append(orderByConditionFields[i]);
18490    
18491                                    if ((i + 1) < orderByConditionFields.length) {
18492                                            if (orderByComparator.isAscending() ^ previous) {
18493                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18494                                            }
18495                                            else {
18496                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18497                                            }
18498                                    }
18499                                    else {
18500                                            if (orderByComparator.isAscending() ^ previous) {
18501                                                    query.append(WHERE_GREATER_THAN);
18502                                            }
18503                                            else {
18504                                                    query.append(WHERE_LESSER_THAN);
18505                                            }
18506                                    }
18507                            }
18508    
18509                            query.append(ORDER_BY_CLAUSE);
18510    
18511                            String[] orderByFields = orderByComparator.getOrderByFields();
18512    
18513                            for (int i = 0; i < orderByFields.length; i++) {
18514                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18515                                    query.append(orderByFields[i]);
18516    
18517                                    if ((i + 1) < orderByFields.length) {
18518                                            if (orderByComparator.isAscending() ^ previous) {
18519                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18520                                            }
18521                                            else {
18522                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18523                                            }
18524                                    }
18525                                    else {
18526                                            if (orderByComparator.isAscending() ^ previous) {
18527                                                    query.append(ORDER_BY_ASC);
18528                                            }
18529                                            else {
18530                                                    query.append(ORDER_BY_DESC);
18531                                            }
18532                                    }
18533                            }
18534                    }
18535                    else {
18536                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18537                    }
18538    
18539                    String sql = query.toString();
18540    
18541                    Query q = session.createQuery(sql);
18542    
18543                    q.setFirstResult(0);
18544                    q.setMaxResults(2);
18545    
18546                    QueryPos qPos = QueryPos.getInstance(q);
18547    
18548                    qPos.add(groupId);
18549    
18550                    qPos.add(userId);
18551    
18552                    qPos.add(classNameId);
18553    
18554                    if (orderByComparator != null) {
18555                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18556    
18557                            for (Object value : values) {
18558                                    qPos.add(value);
18559                            }
18560                    }
18561    
18562                    List<JournalArticle> list = q.list();
18563    
18564                    if (list.size() == 2) {
18565                            return list.get(1);
18566                    }
18567                    else {
18568                            return null;
18569                    }
18570            }
18571    
18572            /**
18573             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18574             *
18575             * @param groupId the group ID
18576             * @param userId the user ID
18577             * @param classNameId the class name ID
18578             * @return the matching journal articles that the user has permission to view
18579             * @throws SystemException if a system exception occurred
18580             */
18581            @Override
18582            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18583                    long classNameId) throws SystemException {
18584                    return filterFindByG_U_C(groupId, userId, classNameId,
18585                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18586            }
18587    
18588            /**
18589             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18590             *
18591             * <p>
18592             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18593             * </p>
18594             *
18595             * @param groupId the group ID
18596             * @param userId the user ID
18597             * @param classNameId the class name ID
18598             * @param start the lower bound of the range of journal articles
18599             * @param end the upper bound of the range of journal articles (not inclusive)
18600             * @return the range of matching journal articles that the user has permission to view
18601             * @throws SystemException if a system exception occurred
18602             */
18603            @Override
18604            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18605                    long classNameId, int start, int end) throws SystemException {
18606                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
18607            }
18608    
18609            /**
18610             * 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;.
18611             *
18612             * <p>
18613             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18614             * </p>
18615             *
18616             * @param groupId the group ID
18617             * @param userId the user ID
18618             * @param classNameId the class name ID
18619             * @param start the lower bound of the range of journal articles
18620             * @param end the upper bound of the range of journal articles (not inclusive)
18621             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18622             * @return the ordered range of matching journal articles that the user has permission to view
18623             * @throws SystemException if a system exception occurred
18624             */
18625            @Override
18626            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18627                    long classNameId, int start, int end,
18628                    OrderByComparator orderByComparator) throws SystemException {
18629                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18630                            return findByG_U_C(groupId, userId, classNameId, start, end,
18631                                    orderByComparator);
18632                    }
18633    
18634                    StringBundler query = null;
18635    
18636                    if (orderByComparator != null) {
18637                            query = new StringBundler(5 +
18638                                            (orderByComparator.getOrderByFields().length * 3));
18639                    }
18640                    else {
18641                            query = new StringBundler(5);
18642                    }
18643    
18644                    if (getDB().isSupportsInlineDistinct()) {
18645                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18646                    }
18647                    else {
18648                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18649                    }
18650    
18651                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18652    
18653                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18654    
18655                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18656    
18657                    if (!getDB().isSupportsInlineDistinct()) {
18658                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18659                    }
18660    
18661                    if (orderByComparator != null) {
18662                            if (getDB().isSupportsInlineDistinct()) {
18663                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18664                                            orderByComparator, true);
18665                            }
18666                            else {
18667                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18668                                            orderByComparator, true);
18669                            }
18670                    }
18671                    else {
18672                            if (getDB().isSupportsInlineDistinct()) {
18673                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18674                            }
18675                            else {
18676                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18677                            }
18678                    }
18679    
18680                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18681                                    JournalArticle.class.getName(),
18682                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18683    
18684                    Session session = null;
18685    
18686                    try {
18687                            session = openSession();
18688    
18689                            SQLQuery q = session.createSQLQuery(sql);
18690    
18691                            if (getDB().isSupportsInlineDistinct()) {
18692                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18693                            }
18694                            else {
18695                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18696                            }
18697    
18698                            QueryPos qPos = QueryPos.getInstance(q);
18699    
18700                            qPos.add(groupId);
18701    
18702                            qPos.add(userId);
18703    
18704                            qPos.add(classNameId);
18705    
18706                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18707                                    end);
18708                    }
18709                    catch (Exception e) {
18710                            throw processException(e);
18711                    }
18712                    finally {
18713                            closeSession(session);
18714                    }
18715            }
18716    
18717            /**
18718             * 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;.
18719             *
18720             * @param id the primary key of the current journal article
18721             * @param groupId the group ID
18722             * @param userId the user ID
18723             * @param classNameId the class name ID
18724             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18725             * @return the previous, current, and next journal article
18726             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18727             * @throws SystemException if a system exception occurred
18728             */
18729            @Override
18730            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
18731                    long groupId, long userId, long classNameId,
18732                    OrderByComparator orderByComparator)
18733                    throws NoSuchArticleException, SystemException {
18734                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18735                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
18736                                    orderByComparator);
18737                    }
18738    
18739                    JournalArticle journalArticle = findByPrimaryKey(id);
18740    
18741                    Session session = null;
18742    
18743                    try {
18744                            session = openSession();
18745    
18746                            JournalArticle[] array = new JournalArticleImpl[3];
18747    
18748                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
18749                                            groupId, userId, classNameId, orderByComparator, true);
18750    
18751                            array[1] = journalArticle;
18752    
18753                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
18754                                            groupId, userId, classNameId, orderByComparator, false);
18755    
18756                            return array;
18757                    }
18758                    catch (Exception e) {
18759                            throw processException(e);
18760                    }
18761                    finally {
18762                            closeSession(session);
18763                    }
18764            }
18765    
18766            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
18767                    JournalArticle journalArticle, long groupId, long userId,
18768                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
18769                    StringBundler query = null;
18770    
18771                    if (orderByComparator != null) {
18772                            query = new StringBundler(6 +
18773                                            (orderByComparator.getOrderByFields().length * 6));
18774                    }
18775                    else {
18776                            query = new StringBundler(3);
18777                    }
18778    
18779                    if (getDB().isSupportsInlineDistinct()) {
18780                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18781                    }
18782                    else {
18783                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18784                    }
18785    
18786                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18787    
18788                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18789    
18790                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18791    
18792                    if (!getDB().isSupportsInlineDistinct()) {
18793                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18794                    }
18795    
18796                    if (orderByComparator != null) {
18797                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18798    
18799                            if (orderByConditionFields.length > 0) {
18800                                    query.append(WHERE_AND);
18801                            }
18802    
18803                            for (int i = 0; i < orderByConditionFields.length; i++) {
18804                                    if (getDB().isSupportsInlineDistinct()) {
18805                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18806                                    }
18807                                    else {
18808                                            query.append(_ORDER_BY_ENTITY_TABLE);
18809                                    }
18810    
18811                                    query.append(orderByConditionFields[i]);
18812    
18813                                    if ((i + 1) < orderByConditionFields.length) {
18814                                            if (orderByComparator.isAscending() ^ previous) {
18815                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18816                                            }
18817                                            else {
18818                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18819                                            }
18820                                    }
18821                                    else {
18822                                            if (orderByComparator.isAscending() ^ previous) {
18823                                                    query.append(WHERE_GREATER_THAN);
18824                                            }
18825                                            else {
18826                                                    query.append(WHERE_LESSER_THAN);
18827                                            }
18828                                    }
18829                            }
18830    
18831                            query.append(ORDER_BY_CLAUSE);
18832    
18833                            String[] orderByFields = orderByComparator.getOrderByFields();
18834    
18835                            for (int i = 0; i < orderByFields.length; i++) {
18836                                    if (getDB().isSupportsInlineDistinct()) {
18837                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18838                                    }
18839                                    else {
18840                                            query.append(_ORDER_BY_ENTITY_TABLE);
18841                                    }
18842    
18843                                    query.append(orderByFields[i]);
18844    
18845                                    if ((i + 1) < orderByFields.length) {
18846                                            if (orderByComparator.isAscending() ^ previous) {
18847                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18848                                            }
18849                                            else {
18850                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18851                                            }
18852                                    }
18853                                    else {
18854                                            if (orderByComparator.isAscending() ^ previous) {
18855                                                    query.append(ORDER_BY_ASC);
18856                                            }
18857                                            else {
18858                                                    query.append(ORDER_BY_DESC);
18859                                            }
18860                                    }
18861                            }
18862                    }
18863                    else {
18864                            if (getDB().isSupportsInlineDistinct()) {
18865                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18866                            }
18867                            else {
18868                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18869                            }
18870                    }
18871    
18872                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18873                                    JournalArticle.class.getName(),
18874                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18875    
18876                    SQLQuery q = session.createSQLQuery(sql);
18877    
18878                    q.setFirstResult(0);
18879                    q.setMaxResults(2);
18880    
18881                    if (getDB().isSupportsInlineDistinct()) {
18882                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18883                    }
18884                    else {
18885                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18886                    }
18887    
18888                    QueryPos qPos = QueryPos.getInstance(q);
18889    
18890                    qPos.add(groupId);
18891    
18892                    qPos.add(userId);
18893    
18894                    qPos.add(classNameId);
18895    
18896                    if (orderByComparator != null) {
18897                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18898    
18899                            for (Object value : values) {
18900                                    qPos.add(value);
18901                            }
18902                    }
18903    
18904                    List<JournalArticle> list = q.list();
18905    
18906                    if (list.size() == 2) {
18907                            return list.get(1);
18908                    }
18909                    else {
18910                            return null;
18911                    }
18912            }
18913    
18914            /**
18915             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
18916             *
18917             * @param groupId the group ID
18918             * @param userId the user ID
18919             * @param classNameId the class name ID
18920             * @throws SystemException if a system exception occurred
18921             */
18922            @Override
18923            public void removeByG_U_C(long groupId, long userId, long classNameId)
18924                    throws SystemException {
18925                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
18926                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18927                            remove(journalArticle);
18928                    }
18929            }
18930    
18931            /**
18932             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18933             *
18934             * @param groupId the group ID
18935             * @param userId the user ID
18936             * @param classNameId the class name ID
18937             * @return the number of matching journal articles
18938             * @throws SystemException if a system exception occurred
18939             */
18940            @Override
18941            public int countByG_U_C(long groupId, long userId, long classNameId)
18942                    throws SystemException {
18943                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
18944    
18945                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
18946    
18947                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18948                                    this);
18949    
18950                    if (count == null) {
18951                            StringBundler query = new StringBundler(4);
18952    
18953                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18954    
18955                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18956    
18957                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18958    
18959                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18960    
18961                            String sql = query.toString();
18962    
18963                            Session session = null;
18964    
18965                            try {
18966                                    session = openSession();
18967    
18968                                    Query q = session.createQuery(sql);
18969    
18970                                    QueryPos qPos = QueryPos.getInstance(q);
18971    
18972                                    qPos.add(groupId);
18973    
18974                                    qPos.add(userId);
18975    
18976                                    qPos.add(classNameId);
18977    
18978                                    count = (Long)q.uniqueResult();
18979    
18980                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18981                            }
18982                            catch (Exception e) {
18983                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18984    
18985                                    throw processException(e);
18986                            }
18987                            finally {
18988                                    closeSession(session);
18989                            }
18990                    }
18991    
18992                    return count.intValue();
18993            }
18994    
18995            /**
18996             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18997             *
18998             * @param groupId the group ID
18999             * @param userId the user ID
19000             * @param classNameId the class name ID
19001             * @return the number of matching journal articles that the user has permission to view
19002             * @throws SystemException if a system exception occurred
19003             */
19004            @Override
19005            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
19006                    throws SystemException {
19007                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19008                            return countByG_U_C(groupId, userId, classNameId);
19009                    }
19010    
19011                    StringBundler query = new StringBundler(4);
19012    
19013                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19014    
19015                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19016    
19017                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19018    
19019                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19020    
19021                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19022                                    JournalArticle.class.getName(),
19023                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19024    
19025                    Session session = null;
19026    
19027                    try {
19028                            session = openSession();
19029    
19030                            SQLQuery q = session.createSQLQuery(sql);
19031    
19032                            q.addScalar(COUNT_COLUMN_NAME,
19033                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19034    
19035                            QueryPos qPos = QueryPos.getInstance(q);
19036    
19037                            qPos.add(groupId);
19038    
19039                            qPos.add(userId);
19040    
19041                            qPos.add(classNameId);
19042    
19043                            Long count = (Long)q.uniqueResult();
19044    
19045                            return count.intValue();
19046                    }
19047                    catch (Exception e) {
19048                            throw processException(e);
19049                    }
19050                    finally {
19051                            closeSession(session);
19052                    }
19053            }
19054    
19055            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
19056            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
19057            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
19058            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19059                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19060                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19061                            "findByG_F_ST",
19062                            new String[] {
19063                                    Long.class.getName(), Long.class.getName(),
19064                                    Integer.class.getName(),
19065                                    
19066                            Integer.class.getName(), Integer.class.getName(),
19067                                    OrderByComparator.class.getName()
19068                            });
19069            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
19070                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19071                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19072                            JournalArticleImpl.class,
19073                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
19074                            new String[] {
19075                                    Long.class.getName(), Long.class.getName(),
19076                                    Integer.class.getName()
19077                            },
19078                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19079                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
19080                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
19081                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19082                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19083            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19084                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19085                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
19086                            new String[] {
19087                                    Long.class.getName(), Long.class.getName(),
19088                                    Integer.class.getName()
19089                            });
19090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19091                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19092                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
19093                            new String[] {
19094                                    Long.class.getName(), Long.class.getName(),
19095                                    Integer.class.getName()
19096                            });
19097    
19098            /**
19099             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19100             *
19101             * @param groupId the group ID
19102             * @param folderId the folder ID
19103             * @param status the status
19104             * @return the matching journal articles
19105             * @throws SystemException if a system exception occurred
19106             */
19107            @Override
19108            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19109                    int status) throws SystemException {
19110                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19111                            QueryUtil.ALL_POS, null);
19112            }
19113    
19114            /**
19115             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19116             *
19117             * <p>
19118             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19119             * </p>
19120             *
19121             * @param groupId the group ID
19122             * @param folderId the folder ID
19123             * @param status the status
19124             * @param start the lower bound of the range of journal articles
19125             * @param end the upper bound of the range of journal articles (not inclusive)
19126             * @return the range of matching journal articles
19127             * @throws SystemException if a system exception occurred
19128             */
19129            @Override
19130            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19131                    int status, int start, int end) throws SystemException {
19132                    return findByG_F_ST(groupId, folderId, status, start, end, null);
19133            }
19134    
19135            /**
19136             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19137             *
19138             * <p>
19139             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19140             * </p>
19141             *
19142             * @param groupId the group ID
19143             * @param folderId the folder ID
19144             * @param status the status
19145             * @param start the lower bound of the range of journal articles
19146             * @param end the upper bound of the range of journal articles (not inclusive)
19147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19148             * @return the ordered range of matching journal articles
19149             * @throws SystemException if a system exception occurred
19150             */
19151            @Override
19152            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19153                    int status, int start, int end, OrderByComparator orderByComparator)
19154                    throws SystemException {
19155                    boolean pagination = true;
19156                    FinderPath finderPath = null;
19157                    Object[] finderArgs = null;
19158    
19159                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19160                                    (orderByComparator == null)) {
19161                            pagination = false;
19162                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
19163                            finderArgs = new Object[] { groupId, folderId, status };
19164                    }
19165                    else {
19166                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
19167                            finderArgs = new Object[] {
19168                                            groupId, folderId, status,
19169                                            
19170                                            start, end, orderByComparator
19171                                    };
19172                    }
19173    
19174                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19175                                    finderArgs, this);
19176    
19177                    if ((list != null) && !list.isEmpty()) {
19178                            for (JournalArticle journalArticle : list) {
19179                                    if ((groupId != journalArticle.getGroupId()) ||
19180                                                    (folderId != journalArticle.getFolderId()) ||
19181                                                    (status != journalArticle.getStatus())) {
19182                                            list = null;
19183    
19184                                            break;
19185                                    }
19186                            }
19187                    }
19188    
19189                    if (list == null) {
19190                            StringBundler query = null;
19191    
19192                            if (orderByComparator != null) {
19193                                    query = new StringBundler(5 +
19194                                                    (orderByComparator.getOrderByFields().length * 3));
19195                            }
19196                            else {
19197                                    query = new StringBundler(5);
19198                            }
19199    
19200                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19201    
19202                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19203    
19204                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19205    
19206                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19207    
19208                            if (orderByComparator != null) {
19209                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19210                                            orderByComparator);
19211                            }
19212                            else
19213                             if (pagination) {
19214                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19215                            }
19216    
19217                            String sql = query.toString();
19218    
19219                            Session session = null;
19220    
19221                            try {
19222                                    session = openSession();
19223    
19224                                    Query q = session.createQuery(sql);
19225    
19226                                    QueryPos qPos = QueryPos.getInstance(q);
19227    
19228                                    qPos.add(groupId);
19229    
19230                                    qPos.add(folderId);
19231    
19232                                    qPos.add(status);
19233    
19234                                    if (!pagination) {
19235                                            list = (List<JournalArticle>)QueryUtil.list(q,
19236                                                            getDialect(), start, end, false);
19237    
19238                                            Collections.sort(list);
19239    
19240                                            list = new UnmodifiableList<JournalArticle>(list);
19241                                    }
19242                                    else {
19243                                            list = (List<JournalArticle>)QueryUtil.list(q,
19244                                                            getDialect(), start, end);
19245                                    }
19246    
19247                                    cacheResult(list);
19248    
19249                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19250                            }
19251                            catch (Exception e) {
19252                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19253    
19254                                    throw processException(e);
19255                            }
19256                            finally {
19257                                    closeSession(session);
19258                            }
19259                    }
19260    
19261                    return list;
19262            }
19263    
19264            /**
19265             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19266             *
19267             * @param groupId the group ID
19268             * @param folderId the folder ID
19269             * @param status the status
19270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19271             * @return the first matching journal article
19272             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19273             * @throws SystemException if a system exception occurred
19274             */
19275            @Override
19276            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
19277                    int status, OrderByComparator orderByComparator)
19278                    throws NoSuchArticleException, SystemException {
19279                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
19280                                    status, orderByComparator);
19281    
19282                    if (journalArticle != null) {
19283                            return journalArticle;
19284                    }
19285    
19286                    StringBundler msg = new StringBundler(8);
19287    
19288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19289    
19290                    msg.append("groupId=");
19291                    msg.append(groupId);
19292    
19293                    msg.append(", folderId=");
19294                    msg.append(folderId);
19295    
19296                    msg.append(", status=");
19297                    msg.append(status);
19298    
19299                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19300    
19301                    throw new NoSuchArticleException(msg.toString());
19302            }
19303    
19304            /**
19305             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19306             *
19307             * @param groupId the group ID
19308             * @param folderId the folder ID
19309             * @param status the status
19310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19311             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19312             * @throws SystemException if a system exception occurred
19313             */
19314            @Override
19315            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
19316                    int status, OrderByComparator orderByComparator)
19317                    throws SystemException {
19318                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
19319                                    1, orderByComparator);
19320    
19321                    if (!list.isEmpty()) {
19322                            return list.get(0);
19323                    }
19324    
19325                    return null;
19326            }
19327    
19328            /**
19329             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19330             *
19331             * @param groupId the group ID
19332             * @param folderId the folder ID
19333             * @param status the status
19334             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19335             * @return the last matching journal article
19336             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19337             * @throws SystemException if a system exception occurred
19338             */
19339            @Override
19340            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
19341                    int status, OrderByComparator orderByComparator)
19342                    throws NoSuchArticleException, SystemException {
19343                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
19344                                    status, orderByComparator);
19345    
19346                    if (journalArticle != null) {
19347                            return journalArticle;
19348                    }
19349    
19350                    StringBundler msg = new StringBundler(8);
19351    
19352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19353    
19354                    msg.append("groupId=");
19355                    msg.append(groupId);
19356    
19357                    msg.append(", folderId=");
19358                    msg.append(folderId);
19359    
19360                    msg.append(", status=");
19361                    msg.append(status);
19362    
19363                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19364    
19365                    throw new NoSuchArticleException(msg.toString());
19366            }
19367    
19368            /**
19369             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19370             *
19371             * @param groupId the group ID
19372             * @param folderId the folder ID
19373             * @param status the status
19374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19375             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19376             * @throws SystemException if a system exception occurred
19377             */
19378            @Override
19379            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
19380                    int status, OrderByComparator orderByComparator)
19381                    throws SystemException {
19382                    int count = countByG_F_ST(groupId, folderId, status);
19383    
19384                    if (count == 0) {
19385                            return null;
19386                    }
19387    
19388                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
19389                                    count - 1, count, orderByComparator);
19390    
19391                    if (!list.isEmpty()) {
19392                            return list.get(0);
19393                    }
19394    
19395                    return null;
19396            }
19397    
19398            /**
19399             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19400             *
19401             * @param id the primary key of the current journal article
19402             * @param groupId the group ID
19403             * @param folderId the folder ID
19404             * @param status the status
19405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19406             * @return the previous, current, and next journal article
19407             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19408             * @throws SystemException if a system exception occurred
19409             */
19410            @Override
19411            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
19412                    long folderId, int status, OrderByComparator orderByComparator)
19413                    throws NoSuchArticleException, SystemException {
19414                    JournalArticle journalArticle = findByPrimaryKey(id);
19415    
19416                    Session session = null;
19417    
19418                    try {
19419                            session = openSession();
19420    
19421                            JournalArticle[] array = new JournalArticleImpl[3];
19422    
19423                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
19424                                            groupId, folderId, status, orderByComparator, true);
19425    
19426                            array[1] = journalArticle;
19427    
19428                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
19429                                            groupId, folderId, status, orderByComparator, false);
19430    
19431                            return array;
19432                    }
19433                    catch (Exception e) {
19434                            throw processException(e);
19435                    }
19436                    finally {
19437                            closeSession(session);
19438                    }
19439            }
19440    
19441            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
19442                    JournalArticle journalArticle, long groupId, long folderId, int status,
19443                    OrderByComparator orderByComparator, boolean previous) {
19444                    StringBundler query = null;
19445    
19446                    if (orderByComparator != null) {
19447                            query = new StringBundler(6 +
19448                                            (orderByComparator.getOrderByFields().length * 6));
19449                    }
19450                    else {
19451                            query = new StringBundler(3);
19452                    }
19453    
19454                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19455    
19456                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19457    
19458                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19459    
19460                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19461    
19462                    if (orderByComparator != null) {
19463                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19464    
19465                            if (orderByConditionFields.length > 0) {
19466                                    query.append(WHERE_AND);
19467                            }
19468    
19469                            for (int i = 0; i < orderByConditionFields.length; i++) {
19470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19471                                    query.append(orderByConditionFields[i]);
19472    
19473                                    if ((i + 1) < orderByConditionFields.length) {
19474                                            if (orderByComparator.isAscending() ^ previous) {
19475                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19476                                            }
19477                                            else {
19478                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19479                                            }
19480                                    }
19481                                    else {
19482                                            if (orderByComparator.isAscending() ^ previous) {
19483                                                    query.append(WHERE_GREATER_THAN);
19484                                            }
19485                                            else {
19486                                                    query.append(WHERE_LESSER_THAN);
19487                                            }
19488                                    }
19489                            }
19490    
19491                            query.append(ORDER_BY_CLAUSE);
19492    
19493                            String[] orderByFields = orderByComparator.getOrderByFields();
19494    
19495                            for (int i = 0; i < orderByFields.length; i++) {
19496                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19497                                    query.append(orderByFields[i]);
19498    
19499                                    if ((i + 1) < orderByFields.length) {
19500                                            if (orderByComparator.isAscending() ^ previous) {
19501                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19502                                            }
19503                                            else {
19504                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19505                                            }
19506                                    }
19507                                    else {
19508                                            if (orderByComparator.isAscending() ^ previous) {
19509                                                    query.append(ORDER_BY_ASC);
19510                                            }
19511                                            else {
19512                                                    query.append(ORDER_BY_DESC);
19513                                            }
19514                                    }
19515                            }
19516                    }
19517                    else {
19518                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19519                    }
19520    
19521                    String sql = query.toString();
19522    
19523                    Query q = session.createQuery(sql);
19524    
19525                    q.setFirstResult(0);
19526                    q.setMaxResults(2);
19527    
19528                    QueryPos qPos = QueryPos.getInstance(q);
19529    
19530                    qPos.add(groupId);
19531    
19532                    qPos.add(folderId);
19533    
19534                    qPos.add(status);
19535    
19536                    if (orderByComparator != null) {
19537                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19538    
19539                            for (Object value : values) {
19540                                    qPos.add(value);
19541                            }
19542                    }
19543    
19544                    List<JournalArticle> list = q.list();
19545    
19546                    if (list.size() == 2) {
19547                            return list.get(1);
19548                    }
19549                    else {
19550                            return null;
19551                    }
19552            }
19553    
19554            /**
19555             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
19556             *
19557             * @param groupId the group ID
19558             * @param folderId the folder ID
19559             * @param status the status
19560             * @return the matching journal articles that the user has permission to view
19561             * @throws SystemException if a system exception occurred
19562             */
19563            @Override
19564            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19565                    int status) throws SystemException {
19566                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19567                            QueryUtil.ALL_POS, null);
19568            }
19569    
19570            /**
19571             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
19572             *
19573             * <p>
19574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19575             * </p>
19576             *
19577             * @param groupId the group ID
19578             * @param folderId the folder ID
19579             * @param status the status
19580             * @param start the lower bound of the range of journal articles
19581             * @param end the upper bound of the range of journal articles (not inclusive)
19582             * @return the range of matching journal articles that the user has permission to view
19583             * @throws SystemException if a system exception occurred
19584             */
19585            @Override
19586            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19587                    int status, int start, int end) throws SystemException {
19588                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
19589            }
19590    
19591            /**
19592             * 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;.
19593             *
19594             * <p>
19595             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19596             * </p>
19597             *
19598             * @param groupId the group ID
19599             * @param folderId the folder ID
19600             * @param status the status
19601             * @param start the lower bound of the range of journal articles
19602             * @param end the upper bound of the range of journal articles (not inclusive)
19603             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19604             * @return the ordered range of matching journal articles that the user has permission to view
19605             * @throws SystemException if a system exception occurred
19606             */
19607            @Override
19608            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19609                    int status, int start, int end, OrderByComparator orderByComparator)
19610                    throws SystemException {
19611                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19612                            return findByG_F_ST(groupId, folderId, status, start, end,
19613                                    orderByComparator);
19614                    }
19615    
19616                    StringBundler query = null;
19617    
19618                    if (orderByComparator != null) {
19619                            query = new StringBundler(5 +
19620                                            (orderByComparator.getOrderByFields().length * 3));
19621                    }
19622                    else {
19623                            query = new StringBundler(5);
19624                    }
19625    
19626                    if (getDB().isSupportsInlineDistinct()) {
19627                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19628                    }
19629                    else {
19630                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19631                    }
19632    
19633                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19634    
19635                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19636    
19637                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19638    
19639                    if (!getDB().isSupportsInlineDistinct()) {
19640                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19641                    }
19642    
19643                    if (orderByComparator != null) {
19644                            if (getDB().isSupportsInlineDistinct()) {
19645                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19646                                            orderByComparator, true);
19647                            }
19648                            else {
19649                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19650                                            orderByComparator, true);
19651                            }
19652                    }
19653                    else {
19654                            if (getDB().isSupportsInlineDistinct()) {
19655                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19656                            }
19657                            else {
19658                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19659                            }
19660                    }
19661    
19662                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19663                                    JournalArticle.class.getName(),
19664                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19665    
19666                    Session session = null;
19667    
19668                    try {
19669                            session = openSession();
19670    
19671                            SQLQuery q = session.createSQLQuery(sql);
19672    
19673                            if (getDB().isSupportsInlineDistinct()) {
19674                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19675                            }
19676                            else {
19677                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19678                            }
19679    
19680                            QueryPos qPos = QueryPos.getInstance(q);
19681    
19682                            qPos.add(groupId);
19683    
19684                            qPos.add(folderId);
19685    
19686                            qPos.add(status);
19687    
19688                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19689                                    end);
19690                    }
19691                    catch (Exception e) {
19692                            throw processException(e);
19693                    }
19694                    finally {
19695                            closeSession(session);
19696                    }
19697            }
19698    
19699            /**
19700             * 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;.
19701             *
19702             * @param id the primary key of the current journal article
19703             * @param groupId the group ID
19704             * @param folderId the folder ID
19705             * @param status the status
19706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19707             * @return the previous, current, and next journal article
19708             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19709             * @throws SystemException if a system exception occurred
19710             */
19711            @Override
19712            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
19713                    long groupId, long folderId, int status,
19714                    OrderByComparator orderByComparator)
19715                    throws NoSuchArticleException, SystemException {
19716                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19717                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
19718                                    orderByComparator);
19719                    }
19720    
19721                    JournalArticle journalArticle = findByPrimaryKey(id);
19722    
19723                    Session session = null;
19724    
19725                    try {
19726                            session = openSession();
19727    
19728                            JournalArticle[] array = new JournalArticleImpl[3];
19729    
19730                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
19731                                            groupId, folderId, status, orderByComparator, true);
19732    
19733                            array[1] = journalArticle;
19734    
19735                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
19736                                            groupId, folderId, status, orderByComparator, false);
19737    
19738                            return array;
19739                    }
19740                    catch (Exception e) {
19741                            throw processException(e);
19742                    }
19743                    finally {
19744                            closeSession(session);
19745                    }
19746            }
19747    
19748            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
19749                    JournalArticle journalArticle, long groupId, long folderId, int status,
19750                    OrderByComparator orderByComparator, boolean previous) {
19751                    StringBundler query = null;
19752    
19753                    if (orderByComparator != null) {
19754                            query = new StringBundler(6 +
19755                                            (orderByComparator.getOrderByFields().length * 6));
19756                    }
19757                    else {
19758                            query = new StringBundler(3);
19759                    }
19760    
19761                    if (getDB().isSupportsInlineDistinct()) {
19762                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19763                    }
19764                    else {
19765                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19766                    }
19767    
19768                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19769    
19770                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19771    
19772                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19773    
19774                    if (!getDB().isSupportsInlineDistinct()) {
19775                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19776                    }
19777    
19778                    if (orderByComparator != null) {
19779                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19780    
19781                            if (orderByConditionFields.length > 0) {
19782                                    query.append(WHERE_AND);
19783                            }
19784    
19785                            for (int i = 0; i < orderByConditionFields.length; i++) {
19786                                    if (getDB().isSupportsInlineDistinct()) {
19787                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19788                                    }
19789                                    else {
19790                                            query.append(_ORDER_BY_ENTITY_TABLE);
19791                                    }
19792    
19793                                    query.append(orderByConditionFields[i]);
19794    
19795                                    if ((i + 1) < orderByConditionFields.length) {
19796                                            if (orderByComparator.isAscending() ^ previous) {
19797                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19798                                            }
19799                                            else {
19800                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19801                                            }
19802                                    }
19803                                    else {
19804                                            if (orderByComparator.isAscending() ^ previous) {
19805                                                    query.append(WHERE_GREATER_THAN);
19806                                            }
19807                                            else {
19808                                                    query.append(WHERE_LESSER_THAN);
19809                                            }
19810                                    }
19811                            }
19812    
19813                            query.append(ORDER_BY_CLAUSE);
19814    
19815                            String[] orderByFields = orderByComparator.getOrderByFields();
19816    
19817                            for (int i = 0; i < orderByFields.length; i++) {
19818                                    if (getDB().isSupportsInlineDistinct()) {
19819                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19820                                    }
19821                                    else {
19822                                            query.append(_ORDER_BY_ENTITY_TABLE);
19823                                    }
19824    
19825                                    query.append(orderByFields[i]);
19826    
19827                                    if ((i + 1) < orderByFields.length) {
19828                                            if (orderByComparator.isAscending() ^ previous) {
19829                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19830                                            }
19831                                            else {
19832                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19833                                            }
19834                                    }
19835                                    else {
19836                                            if (orderByComparator.isAscending() ^ previous) {
19837                                                    query.append(ORDER_BY_ASC);
19838                                            }
19839                                            else {
19840                                                    query.append(ORDER_BY_DESC);
19841                                            }
19842                                    }
19843                            }
19844                    }
19845                    else {
19846                            if (getDB().isSupportsInlineDistinct()) {
19847                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19848                            }
19849                            else {
19850                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19851                            }
19852                    }
19853    
19854                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19855                                    JournalArticle.class.getName(),
19856                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19857    
19858                    SQLQuery q = session.createSQLQuery(sql);
19859    
19860                    q.setFirstResult(0);
19861                    q.setMaxResults(2);
19862    
19863                    if (getDB().isSupportsInlineDistinct()) {
19864                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19865                    }
19866                    else {
19867                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19868                    }
19869    
19870                    QueryPos qPos = QueryPos.getInstance(q);
19871    
19872                    qPos.add(groupId);
19873    
19874                    qPos.add(folderId);
19875    
19876                    qPos.add(status);
19877    
19878                    if (orderByComparator != null) {
19879                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19880    
19881                            for (Object value : values) {
19882                                    qPos.add(value);
19883                            }
19884                    }
19885    
19886                    List<JournalArticle> list = q.list();
19887    
19888                    if (list.size() == 2) {
19889                            return list.get(1);
19890                    }
19891                    else {
19892                            return null;
19893                    }
19894            }
19895    
19896            /**
19897             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
19898             *
19899             * @param groupId the group ID
19900             * @param folderId the folder ID
19901             * @param statuses the statuses
19902             * @return the matching journal articles that the user has permission to view
19903             * @throws SystemException if a system exception occurred
19904             */
19905            @Override
19906            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19907                    int[] statuses) throws SystemException {
19908                    return filterFindByG_F_ST(groupId, folderId, statuses,
19909                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19910            }
19911    
19912            /**
19913             * 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;.
19914             *
19915             * <p>
19916             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19917             * </p>
19918             *
19919             * @param groupId the group ID
19920             * @param folderId the folder ID
19921             * @param statuses the statuses
19922             * @param start the lower bound of the range of journal articles
19923             * @param end the upper bound of the range of journal articles (not inclusive)
19924             * @return the range of matching journal articles that the user has permission to view
19925             * @throws SystemException if a system exception occurred
19926             */
19927            @Override
19928            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19929                    int[] statuses, int start, int end) throws SystemException {
19930                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
19931            }
19932    
19933            /**
19934             * 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;.
19935             *
19936             * <p>
19937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19938             * </p>
19939             *
19940             * @param groupId the group ID
19941             * @param folderId the folder ID
19942             * @param statuses the statuses
19943             * @param start the lower bound of the range of journal articles
19944             * @param end the upper bound of the range of journal articles (not inclusive)
19945             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19946             * @return the ordered range of matching journal articles that the user has permission to view
19947             * @throws SystemException if a system exception occurred
19948             */
19949            @Override
19950            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19951                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
19952                    throws SystemException {
19953                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19954                            return findByG_F_ST(groupId, folderId, statuses, start, end,
19955                                    orderByComparator);
19956                    }
19957    
19958                    StringBundler query = new StringBundler();
19959    
19960                    if (getDB().isSupportsInlineDistinct()) {
19961                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19962                    }
19963                    else {
19964                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19965                    }
19966    
19967                    boolean conjunctionable = false;
19968    
19969                    if (conjunctionable) {
19970                            query.append(WHERE_AND);
19971                    }
19972    
19973                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
19974    
19975                    conjunctionable = true;
19976    
19977                    if (conjunctionable) {
19978                            query.append(WHERE_AND);
19979                    }
19980    
19981                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
19982    
19983                    conjunctionable = true;
19984    
19985                    if ((statuses == null) || (statuses.length > 0)) {
19986                            if (conjunctionable) {
19987                                    query.append(WHERE_AND);
19988                            }
19989    
19990                            query.append(StringPool.OPEN_PARENTHESIS);
19991    
19992                            for (int i = 0; i < statuses.length; i++) {
19993                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
19994    
19995                                    if ((i + 1) < statuses.length) {
19996                                            query.append(WHERE_OR);
19997                                    }
19998                            }
19999    
20000                            query.append(StringPool.CLOSE_PARENTHESIS);
20001    
20002                            conjunctionable = true;
20003                    }
20004    
20005                    if (!getDB().isSupportsInlineDistinct()) {
20006                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20007                    }
20008    
20009                    if (orderByComparator != null) {
20010                            if (getDB().isSupportsInlineDistinct()) {
20011                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20012                                            orderByComparator, true);
20013                            }
20014                            else {
20015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20016                                            orderByComparator, true);
20017                            }
20018                    }
20019                    else {
20020                            if (getDB().isSupportsInlineDistinct()) {
20021                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20022                            }
20023                            else {
20024                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20025                            }
20026                    }
20027    
20028                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20029                                    JournalArticle.class.getName(),
20030                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20031    
20032                    Session session = null;
20033    
20034                    try {
20035                            session = openSession();
20036    
20037                            SQLQuery q = session.createSQLQuery(sql);
20038    
20039                            if (getDB().isSupportsInlineDistinct()) {
20040                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20041                            }
20042                            else {
20043                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20044                            }
20045    
20046                            QueryPos qPos = QueryPos.getInstance(q);
20047    
20048                            qPos.add(groupId);
20049    
20050                            qPos.add(folderId);
20051    
20052                            if (statuses != null) {
20053                                    qPos.add(statuses);
20054                            }
20055    
20056                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20057                                    end);
20058                    }
20059                    catch (Exception e) {
20060                            throw processException(e);
20061                    }
20062                    finally {
20063                            closeSession(session);
20064                    }
20065            }
20066    
20067            /**
20068             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20069             *
20070             * <p>
20071             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20072             * </p>
20073             *
20074             * @param groupId the group ID
20075             * @param folderId the folder ID
20076             * @param statuses the statuses
20077             * @return the matching journal articles
20078             * @throws SystemException if a system exception occurred
20079             */
20080            @Override
20081            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20082                    int[] statuses) throws SystemException {
20083                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
20084                            QueryUtil.ALL_POS, null);
20085            }
20086    
20087            /**
20088             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20089             *
20090             * <p>
20091             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20092             * </p>
20093             *
20094             * @param groupId the group ID
20095             * @param folderId the folder ID
20096             * @param statuses the statuses
20097             * @param start the lower bound of the range of journal articles
20098             * @param end the upper bound of the range of journal articles (not inclusive)
20099             * @return the range of matching journal articles
20100             * @throws SystemException if a system exception occurred
20101             */
20102            @Override
20103            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20104                    int[] statuses, int start, int end) throws SystemException {
20105                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
20106            }
20107    
20108            /**
20109             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20110             *
20111             * <p>
20112             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20113             * </p>
20114             *
20115             * @param groupId the group ID
20116             * @param folderId the folder ID
20117             * @param statuses the statuses
20118             * @param start the lower bound of the range of journal articles
20119             * @param end the upper bound of the range of journal articles (not inclusive)
20120             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20121             * @return the ordered range of matching journal articles
20122             * @throws SystemException if a system exception occurred
20123             */
20124            @Override
20125            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20126                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
20127                    throws SystemException {
20128                    if ((statuses != null) && (statuses.length == 1)) {
20129                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
20130                                    orderByComparator);
20131                    }
20132    
20133                    boolean pagination = true;
20134                    Object[] finderArgs = null;
20135    
20136                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20137                                    (orderByComparator == null)) {
20138                            pagination = false;
20139                            finderArgs = new Object[] {
20140                                            groupId, folderId, StringUtil.merge(statuses)
20141                                    };
20142                    }
20143                    else {
20144                            finderArgs = new Object[] {
20145                                            groupId, folderId, StringUtil.merge(statuses),
20146                                            
20147                                            start, end, orderByComparator
20148                                    };
20149                    }
20150    
20151                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20152                                    finderArgs, this);
20153    
20154                    if ((list != null) && !list.isEmpty()) {
20155                            for (JournalArticle journalArticle : list) {
20156                                    if ((groupId != journalArticle.getGroupId()) ||
20157                                                    (folderId != journalArticle.getFolderId()) ||
20158                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
20159                                            list = null;
20160    
20161                                            break;
20162                                    }
20163                            }
20164                    }
20165    
20166                    if (list == null) {
20167                            StringBundler query = new StringBundler();
20168    
20169                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20170    
20171                            boolean conjunctionable = false;
20172    
20173                            if (conjunctionable) {
20174                                    query.append(WHERE_AND);
20175                            }
20176    
20177                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
20178    
20179                            conjunctionable = true;
20180    
20181                            if (conjunctionable) {
20182                                    query.append(WHERE_AND);
20183                            }
20184    
20185                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
20186    
20187                            conjunctionable = true;
20188    
20189                            if ((statuses == null) || (statuses.length > 0)) {
20190                                    if (conjunctionable) {
20191                                            query.append(WHERE_AND);
20192                                    }
20193    
20194                                    query.append(StringPool.OPEN_PARENTHESIS);
20195    
20196                                    for (int i = 0; i < statuses.length; i++) {
20197                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
20198    
20199                                            if ((i + 1) < statuses.length) {
20200                                                    query.append(WHERE_OR);
20201                                            }
20202                                    }
20203    
20204                                    query.append(StringPool.CLOSE_PARENTHESIS);
20205    
20206                                    conjunctionable = true;
20207                            }
20208    
20209                            if (orderByComparator != null) {
20210                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20211                                            orderByComparator);
20212                            }
20213                            else
20214                             if (pagination) {
20215                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20216                            }
20217    
20218                            String sql = query.toString();
20219    
20220                            Session session = null;
20221    
20222                            try {
20223                                    session = openSession();
20224    
20225                                    Query q = session.createQuery(sql);
20226    
20227                                    QueryPos qPos = QueryPos.getInstance(q);
20228    
20229                                    qPos.add(groupId);
20230    
20231                                    qPos.add(folderId);
20232    
20233                                    if (statuses != null) {
20234                                            qPos.add(statuses);
20235                                    }
20236    
20237                                    if (!pagination) {
20238                                            list = (List<JournalArticle>)QueryUtil.list(q,
20239                                                            getDialect(), start, end, false);
20240    
20241                                            Collections.sort(list);
20242    
20243                                            list = new UnmodifiableList<JournalArticle>(list);
20244                                    }
20245                                    else {
20246                                            list = (List<JournalArticle>)QueryUtil.list(q,
20247                                                            getDialect(), start, end);
20248                                    }
20249    
20250                                    cacheResult(list);
20251    
20252                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20253                                            finderArgs, list);
20254                            }
20255                            catch (Exception e) {
20256                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20257                                            finderArgs);
20258    
20259                                    throw processException(e);
20260                            }
20261                            finally {
20262                                    closeSession(session);
20263                            }
20264                    }
20265    
20266                    return list;
20267            }
20268    
20269            /**
20270             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
20271             *
20272             * @param groupId the group ID
20273             * @param folderId the folder ID
20274             * @param status the status
20275             * @throws SystemException if a system exception occurred
20276             */
20277            @Override
20278            public void removeByG_F_ST(long groupId, long folderId, int status)
20279                    throws SystemException {
20280                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
20281                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20282                            remove(journalArticle);
20283                    }
20284            }
20285    
20286            /**
20287             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
20288             *
20289             * @param groupId the group ID
20290             * @param folderId the folder ID
20291             * @param status the status
20292             * @return the number of matching journal articles
20293             * @throws SystemException if a system exception occurred
20294             */
20295            @Override
20296            public int countByG_F_ST(long groupId, long folderId, int status)
20297                    throws SystemException {
20298                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
20299    
20300                    Object[] finderArgs = new Object[] { groupId, folderId, status };
20301    
20302                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20303                                    this);
20304    
20305                    if (count == null) {
20306                            StringBundler query = new StringBundler(4);
20307    
20308                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20309    
20310                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20311    
20312                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20313    
20314                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20315    
20316                            String sql = query.toString();
20317    
20318                            Session session = null;
20319    
20320                            try {
20321                                    session = openSession();
20322    
20323                                    Query q = session.createQuery(sql);
20324    
20325                                    QueryPos qPos = QueryPos.getInstance(q);
20326    
20327                                    qPos.add(groupId);
20328    
20329                                    qPos.add(folderId);
20330    
20331                                    qPos.add(status);
20332    
20333                                    count = (Long)q.uniqueResult();
20334    
20335                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20336                            }
20337                            catch (Exception e) {
20338                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20339    
20340                                    throw processException(e);
20341                            }
20342                            finally {
20343                                    closeSession(session);
20344                            }
20345                    }
20346    
20347                    return count.intValue();
20348            }
20349    
20350            /**
20351             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20352             *
20353             * @param groupId the group ID
20354             * @param folderId the folder ID
20355             * @param statuses the statuses
20356             * @return the number of matching journal articles
20357             * @throws SystemException if a system exception occurred
20358             */
20359            @Override
20360            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
20361                    throws SystemException {
20362                    Object[] finderArgs = new Object[] {
20363                                    groupId, folderId, StringUtil.merge(statuses)
20364                            };
20365    
20366                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20367                                    finderArgs, this);
20368    
20369                    if (count == null) {
20370                            StringBundler query = new StringBundler();
20371    
20372                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20373    
20374                            boolean conjunctionable = false;
20375    
20376                            if (conjunctionable) {
20377                                    query.append(WHERE_AND);
20378                            }
20379    
20380                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
20381    
20382                            conjunctionable = true;
20383    
20384                            if (conjunctionable) {
20385                                    query.append(WHERE_AND);
20386                            }
20387    
20388                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
20389    
20390                            conjunctionable = true;
20391    
20392                            if ((statuses == null) || (statuses.length > 0)) {
20393                                    if (conjunctionable) {
20394                                            query.append(WHERE_AND);
20395                                    }
20396    
20397                                    query.append(StringPool.OPEN_PARENTHESIS);
20398    
20399                                    for (int i = 0; i < statuses.length; i++) {
20400                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
20401    
20402                                            if ((i + 1) < statuses.length) {
20403                                                    query.append(WHERE_OR);
20404                                            }
20405                                    }
20406    
20407                                    query.append(StringPool.CLOSE_PARENTHESIS);
20408    
20409                                    conjunctionable = true;
20410                            }
20411    
20412                            String sql = query.toString();
20413    
20414                            Session session = null;
20415    
20416                            try {
20417                                    session = openSession();
20418    
20419                                    Query q = session.createQuery(sql);
20420    
20421                                    QueryPos qPos = QueryPos.getInstance(q);
20422    
20423                                    qPos.add(groupId);
20424    
20425                                    qPos.add(folderId);
20426    
20427                                    if (statuses != null) {
20428                                            qPos.add(statuses);
20429                                    }
20430    
20431                                    count = (Long)q.uniqueResult();
20432    
20433                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20434                                            finderArgs, count);
20435                            }
20436                            catch (Exception e) {
20437                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20438                                            finderArgs);
20439    
20440                                    throw processException(e);
20441                            }
20442                            finally {
20443                                    closeSession(session);
20444                            }
20445                    }
20446    
20447                    return count.intValue();
20448            }
20449    
20450            /**
20451             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20452             *
20453             * @param groupId the group ID
20454             * @param folderId the folder ID
20455             * @param status the status
20456             * @return the number of matching journal articles that the user has permission to view
20457             * @throws SystemException if a system exception occurred
20458             */
20459            @Override
20460            public int filterCountByG_F_ST(long groupId, long folderId, int status)
20461                    throws SystemException {
20462                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20463                            return countByG_F_ST(groupId, folderId, status);
20464                    }
20465    
20466                    StringBundler query = new StringBundler(4);
20467    
20468                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20469    
20470                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20471    
20472                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20473    
20474                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20475    
20476                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20477                                    JournalArticle.class.getName(),
20478                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20479    
20480                    Session session = null;
20481    
20482                    try {
20483                            session = openSession();
20484    
20485                            SQLQuery q = session.createSQLQuery(sql);
20486    
20487                            q.addScalar(COUNT_COLUMN_NAME,
20488                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20489    
20490                            QueryPos qPos = QueryPos.getInstance(q);
20491    
20492                            qPos.add(groupId);
20493    
20494                            qPos.add(folderId);
20495    
20496                            qPos.add(status);
20497    
20498                            Long count = (Long)q.uniqueResult();
20499    
20500                            return count.intValue();
20501                    }
20502                    catch (Exception e) {
20503                            throw processException(e);
20504                    }
20505                    finally {
20506                            closeSession(session);
20507                    }
20508            }
20509    
20510            /**
20511             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20512             *
20513             * @param groupId the group ID
20514             * @param folderId the folder ID
20515             * @param statuses the statuses
20516             * @return the number of matching journal articles that the user has permission to view
20517             * @throws SystemException if a system exception occurred
20518             */
20519            @Override
20520            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
20521                    throws SystemException {
20522                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20523                            return countByG_F_ST(groupId, folderId, statuses);
20524                    }
20525    
20526                    StringBundler query = new StringBundler();
20527    
20528                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20529    
20530                    boolean conjunctionable = false;
20531    
20532                    if (conjunctionable) {
20533                            query.append(WHERE_AND);
20534                    }
20535    
20536                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
20537    
20538                    conjunctionable = true;
20539    
20540                    if (conjunctionable) {
20541                            query.append(WHERE_AND);
20542                    }
20543    
20544                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
20545    
20546                    conjunctionable = true;
20547    
20548                    if ((statuses == null) || (statuses.length > 0)) {
20549                            if (conjunctionable) {
20550                                    query.append(WHERE_AND);
20551                            }
20552    
20553                            query.append(StringPool.OPEN_PARENTHESIS);
20554    
20555                            for (int i = 0; i < statuses.length; i++) {
20556                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
20557    
20558                                    if ((i + 1) < statuses.length) {
20559                                            query.append(WHERE_OR);
20560                                    }
20561                            }
20562    
20563                            query.append(StringPool.CLOSE_PARENTHESIS);
20564    
20565                            conjunctionable = true;
20566                    }
20567    
20568                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20569                                    JournalArticle.class.getName(),
20570                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20571    
20572                    Session session = null;
20573    
20574                    try {
20575                            session = openSession();
20576    
20577                            SQLQuery q = session.createSQLQuery(sql);
20578    
20579                            q.addScalar(COUNT_COLUMN_NAME,
20580                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20581    
20582                            QueryPos qPos = QueryPos.getInstance(q);
20583    
20584                            qPos.add(groupId);
20585    
20586                            qPos.add(folderId);
20587    
20588                            if (statuses != null) {
20589                                    qPos.add(statuses);
20590                            }
20591    
20592                            Long count = (Long)q.uniqueResult();
20593    
20594                            return count.intValue();
20595                    }
20596                    catch (Exception e) {
20597                            throw processException(e);
20598                    }
20599                    finally {
20600                            closeSession(session);
20601                    }
20602            }
20603    
20604            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
20605            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
20606                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
20607            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
20608            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
20609                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
20610            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
20611            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
20612                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
20613            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20614                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20615                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20616                            "findByG_C_C",
20617                            new String[] {
20618                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
20619                                    
20620                            Integer.class.getName(), Integer.class.getName(),
20621                                    OrderByComparator.class.getName()
20622                            });
20623            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20624                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20625                            JournalArticleImpl.class,
20626                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
20627                            new String[] {
20628                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20629                            },
20630                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20631                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20632                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
20633                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20634                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20635            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20636                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20637                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
20638                            new String[] {
20639                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20640                            });
20641    
20642            /**
20643             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20644             *
20645             * @param groupId the group ID
20646             * @param classNameId the class name ID
20647             * @param classPK the class p k
20648             * @return the matching journal articles
20649             * @throws SystemException if a system exception occurred
20650             */
20651            @Override
20652            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20653                    long classPK) throws SystemException {
20654                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
20655                            QueryUtil.ALL_POS, null);
20656            }
20657    
20658            /**
20659             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20660             *
20661             * <p>
20662             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20663             * </p>
20664             *
20665             * @param groupId the group ID
20666             * @param classNameId the class name ID
20667             * @param classPK the class p k
20668             * @param start the lower bound of the range of journal articles
20669             * @param end the upper bound of the range of journal articles (not inclusive)
20670             * @return the range of matching journal articles
20671             * @throws SystemException if a system exception occurred
20672             */
20673            @Override
20674            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20675                    long classPK, int start, int end) throws SystemException {
20676                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
20677            }
20678    
20679            /**
20680             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20681             *
20682             * <p>
20683             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20684             * </p>
20685             *
20686             * @param groupId the group ID
20687             * @param classNameId the class name ID
20688             * @param classPK the class p k
20689             * @param start the lower bound of the range of journal articles
20690             * @param end the upper bound of the range of journal articles (not inclusive)
20691             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20692             * @return the ordered range of matching journal articles
20693             * @throws SystemException if a system exception occurred
20694             */
20695            @Override
20696            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20697                    long classPK, int start, int end, OrderByComparator orderByComparator)
20698                    throws SystemException {
20699                    boolean pagination = true;
20700                    FinderPath finderPath = null;
20701                    Object[] finderArgs = null;
20702    
20703                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20704                                    (orderByComparator == null)) {
20705                            pagination = false;
20706                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
20707                            finderArgs = new Object[] { groupId, classNameId, classPK };
20708                    }
20709                    else {
20710                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
20711                            finderArgs = new Object[] {
20712                                            groupId, classNameId, classPK,
20713                                            
20714                                            start, end, orderByComparator
20715                                    };
20716                    }
20717    
20718                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20719                                    finderArgs, this);
20720    
20721                    if ((list != null) && !list.isEmpty()) {
20722                            for (JournalArticle journalArticle : list) {
20723                                    if ((groupId != journalArticle.getGroupId()) ||
20724                                                    (classNameId != journalArticle.getClassNameId()) ||
20725                                                    (classPK != journalArticle.getClassPK())) {
20726                                            list = null;
20727    
20728                                            break;
20729                                    }
20730                            }
20731                    }
20732    
20733                    if (list == null) {
20734                            StringBundler query = null;
20735    
20736                            if (orderByComparator != null) {
20737                                    query = new StringBundler(5 +
20738                                                    (orderByComparator.getOrderByFields().length * 3));
20739                            }
20740                            else {
20741                                    query = new StringBundler(5);
20742                            }
20743    
20744                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20745    
20746                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
20747    
20748                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
20749    
20750                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
20751    
20752                            if (orderByComparator != null) {
20753                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20754                                            orderByComparator);
20755                            }
20756                            else
20757                             if (pagination) {
20758                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20759                            }
20760    
20761                            String sql = query.toString();
20762    
20763                            Session session = null;
20764    
20765                            try {
20766                                    session = openSession();
20767    
20768                                    Query q = session.createQuery(sql);
20769    
20770                                    QueryPos qPos = QueryPos.getInstance(q);
20771    
20772                                    qPos.add(groupId);
20773    
20774                                    qPos.add(classNameId);
20775    
20776                                    qPos.add(classPK);
20777    
20778                                    if (!pagination) {
20779                                            list = (List<JournalArticle>)QueryUtil.list(q,
20780                                                            getDialect(), start, end, false);
20781    
20782                                            Collections.sort(list);
20783    
20784                                            list = new UnmodifiableList<JournalArticle>(list);
20785                                    }
20786                                    else {
20787                                            list = (List<JournalArticle>)QueryUtil.list(q,
20788                                                            getDialect(), start, end);
20789                                    }
20790    
20791                                    cacheResult(list);
20792    
20793                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20794                            }
20795                            catch (Exception e) {
20796                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20797    
20798                                    throw processException(e);
20799                            }
20800                            finally {
20801                                    closeSession(session);
20802                            }
20803                    }
20804    
20805                    return list;
20806            }
20807    
20808            /**
20809             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20810             *
20811             * @param groupId the group ID
20812             * @param classNameId the class name ID
20813             * @param classPK the class p k
20814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20815             * @return the first matching journal article
20816             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20817             * @throws SystemException if a system exception occurred
20818             */
20819            @Override
20820            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
20821                    long classPK, OrderByComparator orderByComparator)
20822                    throws NoSuchArticleException, SystemException {
20823                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
20824                                    classNameId, classPK, orderByComparator);
20825    
20826                    if (journalArticle != null) {
20827                            return journalArticle;
20828                    }
20829    
20830                    StringBundler msg = new StringBundler(8);
20831    
20832                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20833    
20834                    msg.append("groupId=");
20835                    msg.append(groupId);
20836    
20837                    msg.append(", classNameId=");
20838                    msg.append(classNameId);
20839    
20840                    msg.append(", classPK=");
20841                    msg.append(classPK);
20842    
20843                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20844    
20845                    throw new NoSuchArticleException(msg.toString());
20846            }
20847    
20848            /**
20849             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20850             *
20851             * @param groupId the group ID
20852             * @param classNameId the class name ID
20853             * @param classPK the class p k
20854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20855             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
20856             * @throws SystemException if a system exception occurred
20857             */
20858            @Override
20859            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
20860                    long classPK, OrderByComparator orderByComparator)
20861                    throws SystemException {
20862                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
20863                                    0, 1, orderByComparator);
20864    
20865                    if (!list.isEmpty()) {
20866                            return list.get(0);
20867                    }
20868    
20869                    return null;
20870            }
20871    
20872            /**
20873             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20874             *
20875             * @param groupId the group ID
20876             * @param classNameId the class name ID
20877             * @param classPK the class p k
20878             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20879             * @return the last matching journal article
20880             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20881             * @throws SystemException if a system exception occurred
20882             */
20883            @Override
20884            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
20885                    long classPK, OrderByComparator orderByComparator)
20886                    throws NoSuchArticleException, SystemException {
20887                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
20888                                    classPK, orderByComparator);
20889    
20890                    if (journalArticle != null) {
20891                            return journalArticle;
20892                    }
20893    
20894                    StringBundler msg = new StringBundler(8);
20895    
20896                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20897    
20898                    msg.append("groupId=");
20899                    msg.append(groupId);
20900    
20901                    msg.append(", classNameId=");
20902                    msg.append(classNameId);
20903    
20904                    msg.append(", classPK=");
20905                    msg.append(classPK);
20906    
20907                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20908    
20909                    throw new NoSuchArticleException(msg.toString());
20910            }
20911    
20912            /**
20913             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20914             *
20915             * @param groupId the group ID
20916             * @param classNameId the class name ID
20917             * @param classPK the class p k
20918             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20919             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20920             * @throws SystemException if a system exception occurred
20921             */
20922            @Override
20923            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
20924                    long classPK, OrderByComparator orderByComparator)
20925                    throws SystemException {
20926                    int count = countByG_C_C(groupId, classNameId, classPK);
20927    
20928                    if (count == 0) {
20929                            return null;
20930                    }
20931    
20932                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
20933                                    count - 1, count, orderByComparator);
20934    
20935                    if (!list.isEmpty()) {
20936                            return list.get(0);
20937                    }
20938    
20939                    return null;
20940            }
20941    
20942            /**
20943             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20944             *
20945             * @param id the primary key of the current journal article
20946             * @param groupId the group ID
20947             * @param classNameId the class name ID
20948             * @param classPK the class p k
20949             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20950             * @return the previous, current, and next journal article
20951             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20952             * @throws SystemException if a system exception occurred
20953             */
20954            @Override
20955            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
20956                    long classNameId, long classPK, OrderByComparator orderByComparator)
20957                    throws NoSuchArticleException, SystemException {
20958                    JournalArticle journalArticle = findByPrimaryKey(id);
20959    
20960                    Session session = null;
20961    
20962                    try {
20963                            session = openSession();
20964    
20965                            JournalArticle[] array = new JournalArticleImpl[3];
20966    
20967                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
20968                                            classNameId, classPK, orderByComparator, true);
20969    
20970                            array[1] = journalArticle;
20971    
20972                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
20973                                            classNameId, classPK, orderByComparator, false);
20974    
20975                            return array;
20976                    }
20977                    catch (Exception e) {
20978                            throw processException(e);
20979                    }
20980                    finally {
20981                            closeSession(session);
20982                    }
20983            }
20984    
20985            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
20986                    JournalArticle journalArticle, long groupId, long classNameId,
20987                    long classPK, OrderByComparator orderByComparator, boolean previous) {
20988                    StringBundler query = null;
20989    
20990                    if (orderByComparator != null) {
20991                            query = new StringBundler(6 +
20992                                            (orderByComparator.getOrderByFields().length * 6));
20993                    }
20994                    else {
20995                            query = new StringBundler(3);
20996                    }
20997    
20998                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20999    
21000                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21001    
21002                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21003    
21004                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21005    
21006                    if (orderByComparator != null) {
21007                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21008    
21009                            if (orderByConditionFields.length > 0) {
21010                                    query.append(WHERE_AND);
21011                            }
21012    
21013                            for (int i = 0; i < orderByConditionFields.length; i++) {
21014                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21015                                    query.append(orderByConditionFields[i]);
21016    
21017                                    if ((i + 1) < orderByConditionFields.length) {
21018                                            if (orderByComparator.isAscending() ^ previous) {
21019                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21020                                            }
21021                                            else {
21022                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21023                                            }
21024                                    }
21025                                    else {
21026                                            if (orderByComparator.isAscending() ^ previous) {
21027                                                    query.append(WHERE_GREATER_THAN);
21028                                            }
21029                                            else {
21030                                                    query.append(WHERE_LESSER_THAN);
21031                                            }
21032                                    }
21033                            }
21034    
21035                            query.append(ORDER_BY_CLAUSE);
21036    
21037                            String[] orderByFields = orderByComparator.getOrderByFields();
21038    
21039                            for (int i = 0; i < orderByFields.length; i++) {
21040                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21041                                    query.append(orderByFields[i]);
21042    
21043                                    if ((i + 1) < orderByFields.length) {
21044                                            if (orderByComparator.isAscending() ^ previous) {
21045                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21046                                            }
21047                                            else {
21048                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21049                                            }
21050                                    }
21051                                    else {
21052                                            if (orderByComparator.isAscending() ^ previous) {
21053                                                    query.append(ORDER_BY_ASC);
21054                                            }
21055                                            else {
21056                                                    query.append(ORDER_BY_DESC);
21057                                            }
21058                                    }
21059                            }
21060                    }
21061                    else {
21062                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21063                    }
21064    
21065                    String sql = query.toString();
21066    
21067                    Query q = session.createQuery(sql);
21068    
21069                    q.setFirstResult(0);
21070                    q.setMaxResults(2);
21071    
21072                    QueryPos qPos = QueryPos.getInstance(q);
21073    
21074                    qPos.add(groupId);
21075    
21076                    qPos.add(classNameId);
21077    
21078                    qPos.add(classPK);
21079    
21080                    if (orderByComparator != null) {
21081                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21082    
21083                            for (Object value : values) {
21084                                    qPos.add(value);
21085                            }
21086                    }
21087    
21088                    List<JournalArticle> list = q.list();
21089    
21090                    if (list.size() == 2) {
21091                            return list.get(1);
21092                    }
21093                    else {
21094                            return null;
21095                    }
21096            }
21097    
21098            /**
21099             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21100             *
21101             * @param groupId the group ID
21102             * @param classNameId the class name ID
21103             * @param classPK the class p k
21104             * @return the matching journal articles that the user has permission to view
21105             * @throws SystemException if a system exception occurred
21106             */
21107            @Override
21108            public List<JournalArticle> filterFindByG_C_C(long groupId,
21109                    long classNameId, long classPK) throws SystemException {
21110                    return filterFindByG_C_C(groupId, classNameId, classPK,
21111                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21112            }
21113    
21114            /**
21115             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21116             *
21117             * <p>
21118             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21119             * </p>
21120             *
21121             * @param groupId the group ID
21122             * @param classNameId the class name ID
21123             * @param classPK the class p k
21124             * @param start the lower bound of the range of journal articles
21125             * @param end the upper bound of the range of journal articles (not inclusive)
21126             * @return the range of matching journal articles that the user has permission to view
21127             * @throws SystemException if a system exception occurred
21128             */
21129            @Override
21130            public List<JournalArticle> filterFindByG_C_C(long groupId,
21131                    long classNameId, long classPK, int start, int end)
21132                    throws SystemException {
21133                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
21134            }
21135    
21136            /**
21137             * 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;.
21138             *
21139             * <p>
21140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21141             * </p>
21142             *
21143             * @param groupId the group ID
21144             * @param classNameId the class name ID
21145             * @param classPK the class p k
21146             * @param start the lower bound of the range of journal articles
21147             * @param end the upper bound of the range of journal articles (not inclusive)
21148             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21149             * @return the ordered range of matching journal articles that the user has permission to view
21150             * @throws SystemException if a system exception occurred
21151             */
21152            @Override
21153            public List<JournalArticle> filterFindByG_C_C(long groupId,
21154                    long classNameId, long classPK, int start, int end,
21155                    OrderByComparator orderByComparator) throws SystemException {
21156                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21157                            return findByG_C_C(groupId, classNameId, classPK, start, end,
21158                                    orderByComparator);
21159                    }
21160    
21161                    StringBundler query = null;
21162    
21163                    if (orderByComparator != null) {
21164                            query = new StringBundler(5 +
21165                                            (orderByComparator.getOrderByFields().length * 3));
21166                    }
21167                    else {
21168                            query = new StringBundler(5);
21169                    }
21170    
21171                    if (getDB().isSupportsInlineDistinct()) {
21172                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21173                    }
21174                    else {
21175                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21176                    }
21177    
21178                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21179    
21180                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21181    
21182                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21183    
21184                    if (!getDB().isSupportsInlineDistinct()) {
21185                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21186                    }
21187    
21188                    if (orderByComparator != null) {
21189                            if (getDB().isSupportsInlineDistinct()) {
21190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21191                                            orderByComparator, true);
21192                            }
21193                            else {
21194                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21195                                            orderByComparator, true);
21196                            }
21197                    }
21198                    else {
21199                            if (getDB().isSupportsInlineDistinct()) {
21200                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21201                            }
21202                            else {
21203                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21204                            }
21205                    }
21206    
21207                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21208                                    JournalArticle.class.getName(),
21209                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21210    
21211                    Session session = null;
21212    
21213                    try {
21214                            session = openSession();
21215    
21216                            SQLQuery q = session.createSQLQuery(sql);
21217    
21218                            if (getDB().isSupportsInlineDistinct()) {
21219                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21220                            }
21221                            else {
21222                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21223                            }
21224    
21225                            QueryPos qPos = QueryPos.getInstance(q);
21226    
21227                            qPos.add(groupId);
21228    
21229                            qPos.add(classNameId);
21230    
21231                            qPos.add(classPK);
21232    
21233                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21234                                    end);
21235                    }
21236                    catch (Exception e) {
21237                            throw processException(e);
21238                    }
21239                    finally {
21240                            closeSession(session);
21241                    }
21242            }
21243    
21244            /**
21245             * 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;.
21246             *
21247             * @param id the primary key of the current journal article
21248             * @param groupId the group ID
21249             * @param classNameId the class name ID
21250             * @param classPK the class p k
21251             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21252             * @return the previous, current, and next journal article
21253             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21254             * @throws SystemException if a system exception occurred
21255             */
21256            @Override
21257            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
21258                    long groupId, long classNameId, long classPK,
21259                    OrderByComparator orderByComparator)
21260                    throws NoSuchArticleException, SystemException {
21261                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21262                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
21263                                    orderByComparator);
21264                    }
21265    
21266                    JournalArticle journalArticle = findByPrimaryKey(id);
21267    
21268                    Session session = null;
21269    
21270                    try {
21271                            session = openSession();
21272    
21273                            JournalArticle[] array = new JournalArticleImpl[3];
21274    
21275                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
21276                                            groupId, classNameId, classPK, orderByComparator, true);
21277    
21278                            array[1] = journalArticle;
21279    
21280                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
21281                                            groupId, classNameId, classPK, orderByComparator, false);
21282    
21283                            return array;
21284                    }
21285                    catch (Exception e) {
21286                            throw processException(e);
21287                    }
21288                    finally {
21289                            closeSession(session);
21290                    }
21291            }
21292    
21293            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
21294                    JournalArticle journalArticle, long groupId, long classNameId,
21295                    long classPK, OrderByComparator orderByComparator, boolean previous) {
21296                    StringBundler query = null;
21297    
21298                    if (orderByComparator != null) {
21299                            query = new StringBundler(6 +
21300                                            (orderByComparator.getOrderByFields().length * 6));
21301                    }
21302                    else {
21303                            query = new StringBundler(3);
21304                    }
21305    
21306                    if (getDB().isSupportsInlineDistinct()) {
21307                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21308                    }
21309                    else {
21310                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21311                    }
21312    
21313                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21314    
21315                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21316    
21317                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21318    
21319                    if (!getDB().isSupportsInlineDistinct()) {
21320                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21321                    }
21322    
21323                    if (orderByComparator != null) {
21324                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21325    
21326                            if (orderByConditionFields.length > 0) {
21327                                    query.append(WHERE_AND);
21328                            }
21329    
21330                            for (int i = 0; i < orderByConditionFields.length; i++) {
21331                                    if (getDB().isSupportsInlineDistinct()) {
21332                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21333                                    }
21334                                    else {
21335                                            query.append(_ORDER_BY_ENTITY_TABLE);
21336                                    }
21337    
21338                                    query.append(orderByConditionFields[i]);
21339    
21340                                    if ((i + 1) < orderByConditionFields.length) {
21341                                            if (orderByComparator.isAscending() ^ previous) {
21342                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21343                                            }
21344                                            else {
21345                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21346                                            }
21347                                    }
21348                                    else {
21349                                            if (orderByComparator.isAscending() ^ previous) {
21350                                                    query.append(WHERE_GREATER_THAN);
21351                                            }
21352                                            else {
21353                                                    query.append(WHERE_LESSER_THAN);
21354                                            }
21355                                    }
21356                            }
21357    
21358                            query.append(ORDER_BY_CLAUSE);
21359    
21360                            String[] orderByFields = orderByComparator.getOrderByFields();
21361    
21362                            for (int i = 0; i < orderByFields.length; i++) {
21363                                    if (getDB().isSupportsInlineDistinct()) {
21364                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21365                                    }
21366                                    else {
21367                                            query.append(_ORDER_BY_ENTITY_TABLE);
21368                                    }
21369    
21370                                    query.append(orderByFields[i]);
21371    
21372                                    if ((i + 1) < orderByFields.length) {
21373                                            if (orderByComparator.isAscending() ^ previous) {
21374                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21375                                            }
21376                                            else {
21377                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21378                                            }
21379                                    }
21380                                    else {
21381                                            if (orderByComparator.isAscending() ^ previous) {
21382                                                    query.append(ORDER_BY_ASC);
21383                                            }
21384                                            else {
21385                                                    query.append(ORDER_BY_DESC);
21386                                            }
21387                                    }
21388                            }
21389                    }
21390                    else {
21391                            if (getDB().isSupportsInlineDistinct()) {
21392                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21393                            }
21394                            else {
21395                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21396                            }
21397                    }
21398    
21399                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21400                                    JournalArticle.class.getName(),
21401                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21402    
21403                    SQLQuery q = session.createSQLQuery(sql);
21404    
21405                    q.setFirstResult(0);
21406                    q.setMaxResults(2);
21407    
21408                    if (getDB().isSupportsInlineDistinct()) {
21409                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21410                    }
21411                    else {
21412                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21413                    }
21414    
21415                    QueryPos qPos = QueryPos.getInstance(q);
21416    
21417                    qPos.add(groupId);
21418    
21419                    qPos.add(classNameId);
21420    
21421                    qPos.add(classPK);
21422    
21423                    if (orderByComparator != null) {
21424                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21425    
21426                            for (Object value : values) {
21427                                    qPos.add(value);
21428                            }
21429                    }
21430    
21431                    List<JournalArticle> list = q.list();
21432    
21433                    if (list.size() == 2) {
21434                            return list.get(1);
21435                    }
21436                    else {
21437                            return null;
21438                    }
21439            }
21440    
21441            /**
21442             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
21443             *
21444             * @param groupId the group ID
21445             * @param classNameId the class name ID
21446             * @param classPK the class p k
21447             * @throws SystemException if a system exception occurred
21448             */
21449            @Override
21450            public void removeByG_C_C(long groupId, long classNameId, long classPK)
21451                    throws SystemException {
21452                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
21453                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21454                            remove(journalArticle);
21455                    }
21456            }
21457    
21458            /**
21459             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21460             *
21461             * @param groupId the group ID
21462             * @param classNameId the class name ID
21463             * @param classPK the class p k
21464             * @return the number of matching journal articles
21465             * @throws SystemException if a system exception occurred
21466             */
21467            @Override
21468            public int countByG_C_C(long groupId, long classNameId, long classPK)
21469                    throws SystemException {
21470                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
21471    
21472                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
21473    
21474                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21475                                    this);
21476    
21477                    if (count == null) {
21478                            StringBundler query = new StringBundler(4);
21479    
21480                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21481    
21482                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21483    
21484                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21485    
21486                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21487    
21488                            String sql = query.toString();
21489    
21490                            Session session = null;
21491    
21492                            try {
21493                                    session = openSession();
21494    
21495                                    Query q = session.createQuery(sql);
21496    
21497                                    QueryPos qPos = QueryPos.getInstance(q);
21498    
21499                                    qPos.add(groupId);
21500    
21501                                    qPos.add(classNameId);
21502    
21503                                    qPos.add(classPK);
21504    
21505                                    count = (Long)q.uniqueResult();
21506    
21507                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21508                            }
21509                            catch (Exception e) {
21510                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21511    
21512                                    throw processException(e);
21513                            }
21514                            finally {
21515                                    closeSession(session);
21516                            }
21517                    }
21518    
21519                    return count.intValue();
21520            }
21521    
21522            /**
21523             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21524             *
21525             * @param groupId the group ID
21526             * @param classNameId the class name ID
21527             * @param classPK the class p k
21528             * @return the number of matching journal articles that the user has permission to view
21529             * @throws SystemException if a system exception occurred
21530             */
21531            @Override
21532            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
21533                    throws SystemException {
21534                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21535                            return countByG_C_C(groupId, classNameId, classPK);
21536                    }
21537    
21538                    StringBundler query = new StringBundler(4);
21539    
21540                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21541    
21542                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21543    
21544                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21545    
21546                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21547    
21548                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21549                                    JournalArticle.class.getName(),
21550                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21551    
21552                    Session session = null;
21553    
21554                    try {
21555                            session = openSession();
21556    
21557                            SQLQuery q = session.createSQLQuery(sql);
21558    
21559                            q.addScalar(COUNT_COLUMN_NAME,
21560                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21561    
21562                            QueryPos qPos = QueryPos.getInstance(q);
21563    
21564                            qPos.add(groupId);
21565    
21566                            qPos.add(classNameId);
21567    
21568                            qPos.add(classPK);
21569    
21570                            Long count = (Long)q.uniqueResult();
21571    
21572                            return count.intValue();
21573                    }
21574                    catch (Exception e) {
21575                            throw processException(e);
21576                    }
21577                    finally {
21578                            closeSession(session);
21579                    }
21580            }
21581    
21582            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
21583            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
21584            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
21585            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21586                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21587                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
21588                            new String[] {
21589                                    Long.class.getName(), Long.class.getName(),
21590                                    String.class.getName()
21591                            },
21592                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21593                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
21594                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
21595            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21596                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21597                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
21598                            new String[] {
21599                                    Long.class.getName(), Long.class.getName(),
21600                                    String.class.getName()
21601                            });
21602    
21603            /**
21604             * 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.
21605             *
21606             * @param groupId the group ID
21607             * @param classNameId the class name ID
21608             * @param structureId the structure ID
21609             * @return the matching journal article
21610             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21611             * @throws SystemException if a system exception occurred
21612             */
21613            @Override
21614            public JournalArticle findByG_C_S(long groupId, long classNameId,
21615                    String structureId) throws NoSuchArticleException, SystemException {
21616                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
21617                                    structureId);
21618    
21619                    if (journalArticle == null) {
21620                            StringBundler msg = new StringBundler(8);
21621    
21622                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21623    
21624                            msg.append("groupId=");
21625                            msg.append(groupId);
21626    
21627                            msg.append(", classNameId=");
21628                            msg.append(classNameId);
21629    
21630                            msg.append(", structureId=");
21631                            msg.append(structureId);
21632    
21633                            msg.append(StringPool.CLOSE_CURLY_BRACE);
21634    
21635                            if (_log.isWarnEnabled()) {
21636                                    _log.warn(msg.toString());
21637                            }
21638    
21639                            throw new NoSuchArticleException(msg.toString());
21640                    }
21641    
21642                    return journalArticle;
21643            }
21644    
21645            /**
21646             * 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.
21647             *
21648             * @param groupId the group ID
21649             * @param classNameId the class name ID
21650             * @param structureId the structure ID
21651             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21652             * @throws SystemException if a system exception occurred
21653             */
21654            @Override
21655            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
21656                    String structureId) throws SystemException {
21657                    return fetchByG_C_S(groupId, classNameId, structureId, true);
21658            }
21659    
21660            /**
21661             * 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.
21662             *
21663             * @param groupId the group ID
21664             * @param classNameId the class name ID
21665             * @param structureId the structure ID
21666             * @param retrieveFromCache whether to use the finder cache
21667             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21668             * @throws SystemException if a system exception occurred
21669             */
21670            @Override
21671            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
21672                    String structureId, boolean retrieveFromCache)
21673                    throws SystemException {
21674                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
21675    
21676                    Object result = null;
21677    
21678                    if (retrieveFromCache) {
21679                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
21680                                            finderArgs, this);
21681                    }
21682    
21683                    if (result instanceof JournalArticle) {
21684                            JournalArticle journalArticle = (JournalArticle)result;
21685    
21686                            if ((groupId != journalArticle.getGroupId()) ||
21687                                            (classNameId != journalArticle.getClassNameId()) ||
21688                                            !Validator.equals(structureId,
21689                                                    journalArticle.getStructureId())) {
21690                                    result = null;
21691                            }
21692                    }
21693    
21694                    if (result == null) {
21695                            StringBundler query = new StringBundler(5);
21696    
21697                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21698    
21699                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
21700    
21701                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
21702    
21703                            boolean bindStructureId = false;
21704    
21705                            if (structureId == null) {
21706                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
21707                            }
21708                            else if (structureId.equals(StringPool.BLANK)) {
21709                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
21710                            }
21711                            else {
21712                                    bindStructureId = true;
21713    
21714                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
21715                            }
21716    
21717                            String sql = query.toString();
21718    
21719                            Session session = null;
21720    
21721                            try {
21722                                    session = openSession();
21723    
21724                                    Query q = session.createQuery(sql);
21725    
21726                                    QueryPos qPos = QueryPos.getInstance(q);
21727    
21728                                    qPos.add(groupId);
21729    
21730                                    qPos.add(classNameId);
21731    
21732                                    if (bindStructureId) {
21733                                            qPos.add(structureId);
21734                                    }
21735    
21736                                    List<JournalArticle> list = q.list();
21737    
21738                                    if (list.isEmpty()) {
21739                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
21740                                                    finderArgs, list);
21741                                    }
21742                                    else {
21743                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
21744                                                    _log.warn(
21745                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
21746                                                            StringUtil.merge(finderArgs) +
21747                                                            ") 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.");
21748                                            }
21749    
21750                                            JournalArticle journalArticle = list.get(0);
21751    
21752                                            result = journalArticle;
21753    
21754                                            cacheResult(journalArticle);
21755    
21756                                            if ((journalArticle.getGroupId() != groupId) ||
21757                                                            (journalArticle.getClassNameId() != classNameId) ||
21758                                                            (journalArticle.getStructureId() == null) ||
21759                                                            !journalArticle.getStructureId().equals(structureId)) {
21760                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
21761                                                            finderArgs, journalArticle);
21762                                            }
21763                                    }
21764                            }
21765                            catch (Exception e) {
21766                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
21767                                            finderArgs);
21768    
21769                                    throw processException(e);
21770                            }
21771                            finally {
21772                                    closeSession(session);
21773                            }
21774                    }
21775    
21776                    if (result instanceof List<?>) {
21777                            return null;
21778                    }
21779                    else {
21780                            return (JournalArticle)result;
21781                    }
21782            }
21783    
21784            /**
21785             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
21786             *
21787             * @param groupId the group ID
21788             * @param classNameId the class name ID
21789             * @param structureId the structure ID
21790             * @return the journal article that was removed
21791             * @throws SystemException if a system exception occurred
21792             */
21793            @Override
21794            public JournalArticle removeByG_C_S(long groupId, long classNameId,
21795                    String structureId) throws NoSuchArticleException, SystemException {
21796                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
21797                                    structureId);
21798    
21799                    return remove(journalArticle);
21800            }
21801    
21802            /**
21803             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
21804             *
21805             * @param groupId the group ID
21806             * @param classNameId the class name ID
21807             * @param structureId the structure ID
21808             * @return the number of matching journal articles
21809             * @throws SystemException if a system exception occurred
21810             */
21811            @Override
21812            public int countByG_C_S(long groupId, long classNameId, String structureId)
21813                    throws SystemException {
21814                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
21815    
21816                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
21817    
21818                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21819                                    this);
21820    
21821                    if (count == null) {
21822                            StringBundler query = new StringBundler(4);
21823    
21824                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21825    
21826                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
21827    
21828                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
21829    
21830                            boolean bindStructureId = false;
21831    
21832                            if (structureId == null) {
21833                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
21834                            }
21835                            else if (structureId.equals(StringPool.BLANK)) {
21836                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
21837                            }
21838                            else {
21839                                    bindStructureId = true;
21840    
21841                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
21842                            }
21843    
21844                            String sql = query.toString();
21845    
21846                            Session session = null;
21847    
21848                            try {
21849                                    session = openSession();
21850    
21851                                    Query q = session.createQuery(sql);
21852    
21853                                    QueryPos qPos = QueryPos.getInstance(q);
21854    
21855                                    qPos.add(groupId);
21856    
21857                                    qPos.add(classNameId);
21858    
21859                                    if (bindStructureId) {
21860                                            qPos.add(structureId);
21861                                    }
21862    
21863                                    count = (Long)q.uniqueResult();
21864    
21865                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21866                            }
21867                            catch (Exception e) {
21868                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21869    
21870                                    throw processException(e);
21871                            }
21872                            finally {
21873                                    closeSession(session);
21874                            }
21875                    }
21876    
21877                    return count.intValue();
21878            }
21879    
21880            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
21881            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
21882            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
21883            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
21884            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
21885            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21886                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21887                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
21888                            "findByG_C_T",
21889                            new String[] {
21890                                    Long.class.getName(), Long.class.getName(),
21891                                    String.class.getName(),
21892                                    
21893                            Integer.class.getName(), Integer.class.getName(),
21894                                    OrderByComparator.class.getName()
21895                            });
21896            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21897                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21898                            JournalArticleImpl.class,
21899                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
21900                            new String[] {
21901                                    Long.class.getName(), Long.class.getName(),
21902                                    String.class.getName()
21903                            },
21904                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21905                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
21906                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
21907                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21908                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21909            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21910                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21911                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
21912                            new String[] {
21913                                    Long.class.getName(), Long.class.getName(),
21914                                    String.class.getName()
21915                            });
21916    
21917            /**
21918             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
21919             *
21920             * @param groupId the group ID
21921             * @param classNameId the class name ID
21922             * @param templateId the template ID
21923             * @return the matching journal articles
21924             * @throws SystemException if a system exception occurred
21925             */
21926            @Override
21927            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
21928                    String templateId) throws SystemException {
21929                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
21930                            QueryUtil.ALL_POS, null);
21931            }
21932    
21933            /**
21934             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
21935             *
21936             * <p>
21937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21938             * </p>
21939             *
21940             * @param groupId the group ID
21941             * @param classNameId the class name ID
21942             * @param templateId the template ID
21943             * @param start the lower bound of the range of journal articles
21944             * @param end the upper bound of the range of journal articles (not inclusive)
21945             * @return the range of matching journal articles
21946             * @throws SystemException if a system exception occurred
21947             */
21948            @Override
21949            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
21950                    String templateId, int start, int end) throws SystemException {
21951                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
21952            }
21953    
21954            /**
21955             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
21956             *
21957             * <p>
21958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21959             * </p>
21960             *
21961             * @param groupId the group ID
21962             * @param classNameId the class name ID
21963             * @param templateId the template ID
21964             * @param start the lower bound of the range of journal articles
21965             * @param end the upper bound of the range of journal articles (not inclusive)
21966             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21967             * @return the ordered range of matching journal articles
21968             * @throws SystemException if a system exception occurred
21969             */
21970            @Override
21971            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
21972                    String templateId, int start, int end,
21973                    OrderByComparator orderByComparator) throws SystemException {
21974                    boolean pagination = true;
21975                    FinderPath finderPath = null;
21976                    Object[] finderArgs = null;
21977    
21978                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21979                                    (orderByComparator == null)) {
21980                            pagination = false;
21981                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
21982                            finderArgs = new Object[] { groupId, classNameId, templateId };
21983                    }
21984                    else {
21985                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
21986                            finderArgs = new Object[] {
21987                                            groupId, classNameId, templateId,
21988                                            
21989                                            start, end, orderByComparator
21990                                    };
21991                    }
21992    
21993                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21994                                    finderArgs, this);
21995    
21996                    if ((list != null) && !list.isEmpty()) {
21997                            for (JournalArticle journalArticle : list) {
21998                                    if ((groupId != journalArticle.getGroupId()) ||
21999                                                    (classNameId != journalArticle.getClassNameId()) ||
22000                                                    !Validator.equals(templateId,
22001                                                            journalArticle.getTemplateId())) {
22002                                            list = null;
22003    
22004                                            break;
22005                                    }
22006                            }
22007                    }
22008    
22009                    if (list == null) {
22010                            StringBundler query = null;
22011    
22012                            if (orderByComparator != null) {
22013                                    query = new StringBundler(5 +
22014                                                    (orderByComparator.getOrderByFields().length * 3));
22015                            }
22016                            else {
22017                                    query = new StringBundler(5);
22018                            }
22019    
22020                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22021    
22022                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22023    
22024                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22025    
22026                            boolean bindTemplateId = false;
22027    
22028                            if (templateId == null) {
22029                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22030                            }
22031                            else if (templateId.equals(StringPool.BLANK)) {
22032                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22033                            }
22034                            else {
22035                                    bindTemplateId = true;
22036    
22037                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22038                            }
22039    
22040                            if (orderByComparator != null) {
22041                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22042                                            orderByComparator);
22043                            }
22044                            else
22045                             if (pagination) {
22046                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22047                            }
22048    
22049                            String sql = query.toString();
22050    
22051                            Session session = null;
22052    
22053                            try {
22054                                    session = openSession();
22055    
22056                                    Query q = session.createQuery(sql);
22057    
22058                                    QueryPos qPos = QueryPos.getInstance(q);
22059    
22060                                    qPos.add(groupId);
22061    
22062                                    qPos.add(classNameId);
22063    
22064                                    if (bindTemplateId) {
22065                                            qPos.add(templateId);
22066                                    }
22067    
22068                                    if (!pagination) {
22069                                            list = (List<JournalArticle>)QueryUtil.list(q,
22070                                                            getDialect(), start, end, false);
22071    
22072                                            Collections.sort(list);
22073    
22074                                            list = new UnmodifiableList<JournalArticle>(list);
22075                                    }
22076                                    else {
22077                                            list = (List<JournalArticle>)QueryUtil.list(q,
22078                                                            getDialect(), start, end);
22079                                    }
22080    
22081                                    cacheResult(list);
22082    
22083                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22084                            }
22085                            catch (Exception e) {
22086                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22087    
22088                                    throw processException(e);
22089                            }
22090                            finally {
22091                                    closeSession(session);
22092                            }
22093                    }
22094    
22095                    return list;
22096            }
22097    
22098            /**
22099             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22100             *
22101             * @param groupId the group ID
22102             * @param classNameId the class name ID
22103             * @param templateId the template ID
22104             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22105             * @return the first matching journal article
22106             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22107             * @throws SystemException if a system exception occurred
22108             */
22109            @Override
22110            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
22111                    String templateId, OrderByComparator orderByComparator)
22112                    throws NoSuchArticleException, SystemException {
22113                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
22114                                    classNameId, templateId, orderByComparator);
22115    
22116                    if (journalArticle != null) {
22117                            return journalArticle;
22118                    }
22119    
22120                    StringBundler msg = new StringBundler(8);
22121    
22122                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22123    
22124                    msg.append("groupId=");
22125                    msg.append(groupId);
22126    
22127                    msg.append(", classNameId=");
22128                    msg.append(classNameId);
22129    
22130                    msg.append(", templateId=");
22131                    msg.append(templateId);
22132    
22133                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22134    
22135                    throw new NoSuchArticleException(msg.toString());
22136            }
22137    
22138            /**
22139             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22140             *
22141             * @param groupId the group ID
22142             * @param classNameId the class name ID
22143             * @param templateId the template ID
22144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22145             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
22146             * @throws SystemException if a system exception occurred
22147             */
22148            @Override
22149            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
22150                    String templateId, OrderByComparator orderByComparator)
22151                    throws SystemException {
22152                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
22153                                    templateId, 0, 1, orderByComparator);
22154    
22155                    if (!list.isEmpty()) {
22156                            return list.get(0);
22157                    }
22158    
22159                    return null;
22160            }
22161    
22162            /**
22163             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22164             *
22165             * @param groupId the group ID
22166             * @param classNameId the class name ID
22167             * @param templateId the template ID
22168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22169             * @return the last matching journal article
22170             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22171             * @throws SystemException if a system exception occurred
22172             */
22173            @Override
22174            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
22175                    String templateId, OrderByComparator orderByComparator)
22176                    throws NoSuchArticleException, SystemException {
22177                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
22178                                    templateId, orderByComparator);
22179    
22180                    if (journalArticle != null) {
22181                            return journalArticle;
22182                    }
22183    
22184                    StringBundler msg = new StringBundler(8);
22185    
22186                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22187    
22188                    msg.append("groupId=");
22189                    msg.append(groupId);
22190    
22191                    msg.append(", classNameId=");
22192                    msg.append(classNameId);
22193    
22194                    msg.append(", templateId=");
22195                    msg.append(templateId);
22196    
22197                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22198    
22199                    throw new NoSuchArticleException(msg.toString());
22200            }
22201    
22202            /**
22203             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22204             *
22205             * @param groupId the group ID
22206             * @param classNameId the class name ID
22207             * @param templateId the template ID
22208             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22209             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
22210             * @throws SystemException if a system exception occurred
22211             */
22212            @Override
22213            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
22214                    String templateId, OrderByComparator orderByComparator)
22215                    throws SystemException {
22216                    int count = countByG_C_T(groupId, classNameId, templateId);
22217    
22218                    if (count == 0) {
22219                            return null;
22220                    }
22221    
22222                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
22223                                    templateId, count - 1, count, orderByComparator);
22224    
22225                    if (!list.isEmpty()) {
22226                            return list.get(0);
22227                    }
22228    
22229                    return null;
22230            }
22231    
22232            /**
22233             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22234             *
22235             * @param id the primary key of the current journal article
22236             * @param groupId the group ID
22237             * @param classNameId the class name ID
22238             * @param templateId the template ID
22239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22240             * @return the previous, current, and next journal article
22241             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22242             * @throws SystemException if a system exception occurred
22243             */
22244            @Override
22245            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
22246                    long classNameId, String templateId, OrderByComparator orderByComparator)
22247                    throws NoSuchArticleException, SystemException {
22248                    JournalArticle journalArticle = findByPrimaryKey(id);
22249    
22250                    Session session = null;
22251    
22252                    try {
22253                            session = openSession();
22254    
22255                            JournalArticle[] array = new JournalArticleImpl[3];
22256    
22257                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
22258                                            classNameId, templateId, orderByComparator, true);
22259    
22260                            array[1] = journalArticle;
22261    
22262                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
22263                                            classNameId, templateId, orderByComparator, false);
22264    
22265                            return array;
22266                    }
22267                    catch (Exception e) {
22268                            throw processException(e);
22269                    }
22270                    finally {
22271                            closeSession(session);
22272                    }
22273            }
22274    
22275            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
22276                    JournalArticle journalArticle, long groupId, long classNameId,
22277                    String templateId, OrderByComparator orderByComparator, boolean previous) {
22278                    StringBundler query = null;
22279    
22280                    if (orderByComparator != null) {
22281                            query = new StringBundler(6 +
22282                                            (orderByComparator.getOrderByFields().length * 6));
22283                    }
22284                    else {
22285                            query = new StringBundler(3);
22286                    }
22287    
22288                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22289    
22290                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22291    
22292                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22293    
22294                    boolean bindTemplateId = false;
22295    
22296                    if (templateId == null) {
22297                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22298                    }
22299                    else if (templateId.equals(StringPool.BLANK)) {
22300                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22301                    }
22302                    else {
22303                            bindTemplateId = true;
22304    
22305                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22306                    }
22307    
22308                    if (orderByComparator != null) {
22309                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22310    
22311                            if (orderByConditionFields.length > 0) {
22312                                    query.append(WHERE_AND);
22313                            }
22314    
22315                            for (int i = 0; i < orderByConditionFields.length; i++) {
22316                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22317                                    query.append(orderByConditionFields[i]);
22318    
22319                                    if ((i + 1) < orderByConditionFields.length) {
22320                                            if (orderByComparator.isAscending() ^ previous) {
22321                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22322                                            }
22323                                            else {
22324                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22325                                            }
22326                                    }
22327                                    else {
22328                                            if (orderByComparator.isAscending() ^ previous) {
22329                                                    query.append(WHERE_GREATER_THAN);
22330                                            }
22331                                            else {
22332                                                    query.append(WHERE_LESSER_THAN);
22333                                            }
22334                                    }
22335                            }
22336    
22337                            query.append(ORDER_BY_CLAUSE);
22338    
22339                            String[] orderByFields = orderByComparator.getOrderByFields();
22340    
22341                            for (int i = 0; i < orderByFields.length; i++) {
22342                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22343                                    query.append(orderByFields[i]);
22344    
22345                                    if ((i + 1) < orderByFields.length) {
22346                                            if (orderByComparator.isAscending() ^ previous) {
22347                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22348                                            }
22349                                            else {
22350                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22351                                            }
22352                                    }
22353                                    else {
22354                                            if (orderByComparator.isAscending() ^ previous) {
22355                                                    query.append(ORDER_BY_ASC);
22356                                            }
22357                                            else {
22358                                                    query.append(ORDER_BY_DESC);
22359                                            }
22360                                    }
22361                            }
22362                    }
22363                    else {
22364                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22365                    }
22366    
22367                    String sql = query.toString();
22368    
22369                    Query q = session.createQuery(sql);
22370    
22371                    q.setFirstResult(0);
22372                    q.setMaxResults(2);
22373    
22374                    QueryPos qPos = QueryPos.getInstance(q);
22375    
22376                    qPos.add(groupId);
22377    
22378                    qPos.add(classNameId);
22379    
22380                    if (bindTemplateId) {
22381                            qPos.add(templateId);
22382                    }
22383    
22384                    if (orderByComparator != null) {
22385                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22386    
22387                            for (Object value : values) {
22388                                    qPos.add(value);
22389                            }
22390                    }
22391    
22392                    List<JournalArticle> list = q.list();
22393    
22394                    if (list.size() == 2) {
22395                            return list.get(1);
22396                    }
22397                    else {
22398                            return null;
22399                    }
22400            }
22401    
22402            /**
22403             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22404             *
22405             * @param groupId the group ID
22406             * @param classNameId the class name ID
22407             * @param templateId the template ID
22408             * @return the matching journal articles that the user has permission to view
22409             * @throws SystemException if a system exception occurred
22410             */
22411            @Override
22412            public List<JournalArticle> filterFindByG_C_T(long groupId,
22413                    long classNameId, String templateId) throws SystemException {
22414                    return filterFindByG_C_T(groupId, classNameId, templateId,
22415                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22416            }
22417    
22418            /**
22419             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22420             *
22421             * <p>
22422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22423             * </p>
22424             *
22425             * @param groupId the group ID
22426             * @param classNameId the class name ID
22427             * @param templateId the template ID
22428             * @param start the lower bound of the range of journal articles
22429             * @param end the upper bound of the range of journal articles (not inclusive)
22430             * @return the range of matching journal articles that the user has permission to view
22431             * @throws SystemException if a system exception occurred
22432             */
22433            @Override
22434            public List<JournalArticle> filterFindByG_C_T(long groupId,
22435                    long classNameId, String templateId, int start, int end)
22436                    throws SystemException {
22437                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
22438                            null);
22439            }
22440    
22441            /**
22442             * 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;.
22443             *
22444             * <p>
22445             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22446             * </p>
22447             *
22448             * @param groupId the group ID
22449             * @param classNameId the class name ID
22450             * @param templateId the template ID
22451             * @param start the lower bound of the range of journal articles
22452             * @param end the upper bound of the range of journal articles (not inclusive)
22453             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22454             * @return the ordered range of matching journal articles that the user has permission to view
22455             * @throws SystemException if a system exception occurred
22456             */
22457            @Override
22458            public List<JournalArticle> filterFindByG_C_T(long groupId,
22459                    long classNameId, String templateId, int start, int end,
22460                    OrderByComparator orderByComparator) throws SystemException {
22461                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22462                            return findByG_C_T(groupId, classNameId, templateId, start, end,
22463                                    orderByComparator);
22464                    }
22465    
22466                    StringBundler query = null;
22467    
22468                    if (orderByComparator != null) {
22469                            query = new StringBundler(5 +
22470                                            (orderByComparator.getOrderByFields().length * 3));
22471                    }
22472                    else {
22473                            query = new StringBundler(5);
22474                    }
22475    
22476                    if (getDB().isSupportsInlineDistinct()) {
22477                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22478                    }
22479                    else {
22480                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22481                    }
22482    
22483                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22484    
22485                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22486    
22487                    boolean bindTemplateId = false;
22488    
22489                    if (templateId == null) {
22490                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22491                    }
22492                    else if (templateId.equals(StringPool.BLANK)) {
22493                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22494                    }
22495                    else {
22496                            bindTemplateId = true;
22497    
22498                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22499                    }
22500    
22501                    if (!getDB().isSupportsInlineDistinct()) {
22502                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22503                    }
22504    
22505                    if (orderByComparator != null) {
22506                            if (getDB().isSupportsInlineDistinct()) {
22507                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22508                                            orderByComparator, true);
22509                            }
22510                            else {
22511                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22512                                            orderByComparator, true);
22513                            }
22514                    }
22515                    else {
22516                            if (getDB().isSupportsInlineDistinct()) {
22517                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22518                            }
22519                            else {
22520                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22521                            }
22522                    }
22523    
22524                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22525                                    JournalArticle.class.getName(),
22526                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22527    
22528                    Session session = null;
22529    
22530                    try {
22531                            session = openSession();
22532    
22533                            SQLQuery q = session.createSQLQuery(sql);
22534    
22535                            if (getDB().isSupportsInlineDistinct()) {
22536                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22537                            }
22538                            else {
22539                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22540                            }
22541    
22542                            QueryPos qPos = QueryPos.getInstance(q);
22543    
22544                            qPos.add(groupId);
22545    
22546                            qPos.add(classNameId);
22547    
22548                            if (bindTemplateId) {
22549                                    qPos.add(templateId);
22550                            }
22551    
22552                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22553                                    end);
22554                    }
22555                    catch (Exception e) {
22556                            throw processException(e);
22557                    }
22558                    finally {
22559                            closeSession(session);
22560                    }
22561            }
22562    
22563            /**
22564             * 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;.
22565             *
22566             * @param id the primary key of the current journal article
22567             * @param groupId the group ID
22568             * @param classNameId the class name ID
22569             * @param templateId the template ID
22570             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22571             * @return the previous, current, and next journal article
22572             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22573             * @throws SystemException if a system exception occurred
22574             */
22575            @Override
22576            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
22577                    long groupId, long classNameId, String templateId,
22578                    OrderByComparator orderByComparator)
22579                    throws NoSuchArticleException, SystemException {
22580                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22581                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
22582                                    templateId, orderByComparator);
22583                    }
22584    
22585                    JournalArticle journalArticle = findByPrimaryKey(id);
22586    
22587                    Session session = null;
22588    
22589                    try {
22590                            session = openSession();
22591    
22592                            JournalArticle[] array = new JournalArticleImpl[3];
22593    
22594                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
22595                                            groupId, classNameId, templateId, orderByComparator, true);
22596    
22597                            array[1] = journalArticle;
22598    
22599                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
22600                                            groupId, classNameId, templateId, orderByComparator, false);
22601    
22602                            return array;
22603                    }
22604                    catch (Exception e) {
22605                            throw processException(e);
22606                    }
22607                    finally {
22608                            closeSession(session);
22609                    }
22610            }
22611    
22612            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
22613                    JournalArticle journalArticle, long groupId, long classNameId,
22614                    String templateId, OrderByComparator orderByComparator, boolean previous) {
22615                    StringBundler query = null;
22616    
22617                    if (orderByComparator != null) {
22618                            query = new StringBundler(6 +
22619                                            (orderByComparator.getOrderByFields().length * 6));
22620                    }
22621                    else {
22622                            query = new StringBundler(3);
22623                    }
22624    
22625                    if (getDB().isSupportsInlineDistinct()) {
22626                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22627                    }
22628                    else {
22629                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22630                    }
22631    
22632                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22633    
22634                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22635    
22636                    boolean bindTemplateId = false;
22637    
22638                    if (templateId == null) {
22639                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22640                    }
22641                    else if (templateId.equals(StringPool.BLANK)) {
22642                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22643                    }
22644                    else {
22645                            bindTemplateId = true;
22646    
22647                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22648                    }
22649    
22650                    if (!getDB().isSupportsInlineDistinct()) {
22651                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22652                    }
22653    
22654                    if (orderByComparator != null) {
22655                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22656    
22657                            if (orderByConditionFields.length > 0) {
22658                                    query.append(WHERE_AND);
22659                            }
22660    
22661                            for (int i = 0; i < orderByConditionFields.length; i++) {
22662                                    if (getDB().isSupportsInlineDistinct()) {
22663                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22664                                    }
22665                                    else {
22666                                            query.append(_ORDER_BY_ENTITY_TABLE);
22667                                    }
22668    
22669                                    query.append(orderByConditionFields[i]);
22670    
22671                                    if ((i + 1) < orderByConditionFields.length) {
22672                                            if (orderByComparator.isAscending() ^ previous) {
22673                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22674                                            }
22675                                            else {
22676                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22677                                            }
22678                                    }
22679                                    else {
22680                                            if (orderByComparator.isAscending() ^ previous) {
22681                                                    query.append(WHERE_GREATER_THAN);
22682                                            }
22683                                            else {
22684                                                    query.append(WHERE_LESSER_THAN);
22685                                            }
22686                                    }
22687                            }
22688    
22689                            query.append(ORDER_BY_CLAUSE);
22690    
22691                            String[] orderByFields = orderByComparator.getOrderByFields();
22692    
22693                            for (int i = 0; i < orderByFields.length; i++) {
22694                                    if (getDB().isSupportsInlineDistinct()) {
22695                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22696                                    }
22697                                    else {
22698                                            query.append(_ORDER_BY_ENTITY_TABLE);
22699                                    }
22700    
22701                                    query.append(orderByFields[i]);
22702    
22703                                    if ((i + 1) < orderByFields.length) {
22704                                            if (orderByComparator.isAscending() ^ previous) {
22705                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22706                                            }
22707                                            else {
22708                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22709                                            }
22710                                    }
22711                                    else {
22712                                            if (orderByComparator.isAscending() ^ previous) {
22713                                                    query.append(ORDER_BY_ASC);
22714                                            }
22715                                            else {
22716                                                    query.append(ORDER_BY_DESC);
22717                                            }
22718                                    }
22719                            }
22720                    }
22721                    else {
22722                            if (getDB().isSupportsInlineDistinct()) {
22723                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22724                            }
22725                            else {
22726                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22727                            }
22728                    }
22729    
22730                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22731                                    JournalArticle.class.getName(),
22732                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22733    
22734                    SQLQuery q = session.createSQLQuery(sql);
22735    
22736                    q.setFirstResult(0);
22737                    q.setMaxResults(2);
22738    
22739                    if (getDB().isSupportsInlineDistinct()) {
22740                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22741                    }
22742                    else {
22743                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22744                    }
22745    
22746                    QueryPos qPos = QueryPos.getInstance(q);
22747    
22748                    qPos.add(groupId);
22749    
22750                    qPos.add(classNameId);
22751    
22752                    if (bindTemplateId) {
22753                            qPos.add(templateId);
22754                    }
22755    
22756                    if (orderByComparator != null) {
22757                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22758    
22759                            for (Object value : values) {
22760                                    qPos.add(value);
22761                            }
22762                    }
22763    
22764                    List<JournalArticle> list = q.list();
22765    
22766                    if (list.size() == 2) {
22767                            return list.get(1);
22768                    }
22769                    else {
22770                            return null;
22771                    }
22772            }
22773    
22774            /**
22775             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
22776             *
22777             * @param groupId the group ID
22778             * @param classNameId the class name ID
22779             * @param templateId the template ID
22780             * @throws SystemException if a system exception occurred
22781             */
22782            @Override
22783            public void removeByG_C_T(long groupId, long classNameId, String templateId)
22784                    throws SystemException {
22785                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
22786                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22787                            remove(journalArticle);
22788                    }
22789            }
22790    
22791            /**
22792             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22793             *
22794             * @param groupId the group ID
22795             * @param classNameId the class name ID
22796             * @param templateId the template ID
22797             * @return the number of matching journal articles
22798             * @throws SystemException if a system exception occurred
22799             */
22800            @Override
22801            public int countByG_C_T(long groupId, long classNameId, String templateId)
22802                    throws SystemException {
22803                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
22804    
22805                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
22806    
22807                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22808                                    this);
22809    
22810                    if (count == null) {
22811                            StringBundler query = new StringBundler(4);
22812    
22813                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22814    
22815                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22816    
22817                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22818    
22819                            boolean bindTemplateId = false;
22820    
22821                            if (templateId == null) {
22822                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22823                            }
22824                            else if (templateId.equals(StringPool.BLANK)) {
22825                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22826                            }
22827                            else {
22828                                    bindTemplateId = true;
22829    
22830                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22831                            }
22832    
22833                            String sql = query.toString();
22834    
22835                            Session session = null;
22836    
22837                            try {
22838                                    session = openSession();
22839    
22840                                    Query q = session.createQuery(sql);
22841    
22842                                    QueryPos qPos = QueryPos.getInstance(q);
22843    
22844                                    qPos.add(groupId);
22845    
22846                                    qPos.add(classNameId);
22847    
22848                                    if (bindTemplateId) {
22849                                            qPos.add(templateId);
22850                                    }
22851    
22852                                    count = (Long)q.uniqueResult();
22853    
22854                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22855                            }
22856                            catch (Exception e) {
22857                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22858    
22859                                    throw processException(e);
22860                            }
22861                            finally {
22862                                    closeSession(session);
22863                            }
22864                    }
22865    
22866                    return count.intValue();
22867            }
22868    
22869            /**
22870             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22871             *
22872             * @param groupId the group ID
22873             * @param classNameId the class name ID
22874             * @param templateId the template ID
22875             * @return the number of matching journal articles that the user has permission to view
22876             * @throws SystemException if a system exception occurred
22877             */
22878            @Override
22879            public int filterCountByG_C_T(long groupId, long classNameId,
22880                    String templateId) throws SystemException {
22881                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22882                            return countByG_C_T(groupId, classNameId, templateId);
22883                    }
22884    
22885                    StringBundler query = new StringBundler(4);
22886    
22887                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22888    
22889                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22890    
22891                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22892    
22893                    boolean bindTemplateId = false;
22894    
22895                    if (templateId == null) {
22896                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22897                    }
22898                    else if (templateId.equals(StringPool.BLANK)) {
22899                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22900                    }
22901                    else {
22902                            bindTemplateId = true;
22903    
22904                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22905                    }
22906    
22907                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22908                                    JournalArticle.class.getName(),
22909                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22910    
22911                    Session session = null;
22912    
22913                    try {
22914                            session = openSession();
22915    
22916                            SQLQuery q = session.createSQLQuery(sql);
22917    
22918                            q.addScalar(COUNT_COLUMN_NAME,
22919                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
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                            Long count = (Long)q.uniqueResult();
22932    
22933                            return count.intValue();
22934                    }
22935                    catch (Exception e) {
22936                            throw processException(e);
22937                    }
22938                    finally {
22939                            closeSession(session);
22940                    }
22941            }
22942    
22943            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
22944            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22945            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
22946            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
22947            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
22948            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22949                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22950                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22951                            "findByG_C_L",
22952                            new String[] {
22953                                    Long.class.getName(), Long.class.getName(),
22954                                    String.class.getName(),
22955                                    
22956                            Integer.class.getName(), Integer.class.getName(),
22957                                    OrderByComparator.class.getName()
22958                            });
22959            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22960                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22961                            JournalArticleImpl.class,
22962                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
22963                            new String[] {
22964                                    Long.class.getName(), Long.class.getName(),
22965                                    String.class.getName()
22966                            },
22967                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22968                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22969                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
22970                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22971                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22972            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22973                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22974                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
22975                            new String[] {
22976                                    Long.class.getName(), Long.class.getName(),
22977                                    String.class.getName()
22978                            });
22979    
22980            /**
22981             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
22982             *
22983             * @param groupId the group ID
22984             * @param classNameId the class name ID
22985             * @param layoutUuid the layout uuid
22986             * @return the matching journal articles
22987             * @throws SystemException if a system exception occurred
22988             */
22989            @Override
22990            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
22991                    String layoutUuid) throws SystemException {
22992                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
22993                            QueryUtil.ALL_POS, null);
22994            }
22995    
22996            /**
22997             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
22998             *
22999             * <p>
23000             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23001             * </p>
23002             *
23003             * @param groupId the group ID
23004             * @param classNameId the class name ID
23005             * @param layoutUuid the layout uuid
23006             * @param start the lower bound of the range of journal articles
23007             * @param end the upper bound of the range of journal articles (not inclusive)
23008             * @return the range of matching journal articles
23009             * @throws SystemException if a system exception occurred
23010             */
23011            @Override
23012            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23013                    String layoutUuid, int start, int end) throws SystemException {
23014                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
23015            }
23016    
23017            /**
23018             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23019             *
23020             * <p>
23021             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23022             * </p>
23023             *
23024             * @param groupId the group ID
23025             * @param classNameId the class name ID
23026             * @param layoutUuid the layout uuid
23027             * @param start the lower bound of the range of journal articles
23028             * @param end the upper bound of the range of journal articles (not inclusive)
23029             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23030             * @return the ordered range of matching journal articles
23031             * @throws SystemException if a system exception occurred
23032             */
23033            @Override
23034            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23035                    String layoutUuid, int start, int end,
23036                    OrderByComparator orderByComparator) throws SystemException {
23037                    boolean pagination = true;
23038                    FinderPath finderPath = null;
23039                    Object[] finderArgs = null;
23040    
23041                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23042                                    (orderByComparator == null)) {
23043                            pagination = false;
23044                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
23045                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
23046                    }
23047                    else {
23048                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
23049                            finderArgs = new Object[] {
23050                                            groupId, classNameId, layoutUuid,
23051                                            
23052                                            start, end, orderByComparator
23053                                    };
23054                    }
23055    
23056                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23057                                    finderArgs, this);
23058    
23059                    if ((list != null) && !list.isEmpty()) {
23060                            for (JournalArticle journalArticle : list) {
23061                                    if ((groupId != journalArticle.getGroupId()) ||
23062                                                    (classNameId != journalArticle.getClassNameId()) ||
23063                                                    !Validator.equals(layoutUuid,
23064                                                            journalArticle.getLayoutUuid())) {
23065                                            list = null;
23066    
23067                                            break;
23068                                    }
23069                            }
23070                    }
23071    
23072                    if (list == null) {
23073                            StringBundler query = null;
23074    
23075                            if (orderByComparator != null) {
23076                                    query = new StringBundler(5 +
23077                                                    (orderByComparator.getOrderByFields().length * 3));
23078                            }
23079                            else {
23080                                    query = new StringBundler(5);
23081                            }
23082    
23083                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23084    
23085                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23086    
23087                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23088    
23089                            boolean bindLayoutUuid = false;
23090    
23091                            if (layoutUuid == null) {
23092                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23093                            }
23094                            else if (layoutUuid.equals(StringPool.BLANK)) {
23095                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23096                            }
23097                            else {
23098                                    bindLayoutUuid = true;
23099    
23100                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23101                            }
23102    
23103                            if (orderByComparator != null) {
23104                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23105                                            orderByComparator);
23106                            }
23107                            else
23108                             if (pagination) {
23109                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23110                            }
23111    
23112                            String sql = query.toString();
23113    
23114                            Session session = null;
23115    
23116                            try {
23117                                    session = openSession();
23118    
23119                                    Query q = session.createQuery(sql);
23120    
23121                                    QueryPos qPos = QueryPos.getInstance(q);
23122    
23123                                    qPos.add(groupId);
23124    
23125                                    qPos.add(classNameId);
23126    
23127                                    if (bindLayoutUuid) {
23128                                            qPos.add(layoutUuid);
23129                                    }
23130    
23131                                    if (!pagination) {
23132                                            list = (List<JournalArticle>)QueryUtil.list(q,
23133                                                            getDialect(), start, end, false);
23134    
23135                                            Collections.sort(list);
23136    
23137                                            list = new UnmodifiableList<JournalArticle>(list);
23138                                    }
23139                                    else {
23140                                            list = (List<JournalArticle>)QueryUtil.list(q,
23141                                                            getDialect(), start, end);
23142                                    }
23143    
23144                                    cacheResult(list);
23145    
23146                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23147                            }
23148                            catch (Exception e) {
23149                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23150    
23151                                    throw processException(e);
23152                            }
23153                            finally {
23154                                    closeSession(session);
23155                            }
23156                    }
23157    
23158                    return list;
23159            }
23160    
23161            /**
23162             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23163             *
23164             * @param groupId the group ID
23165             * @param classNameId the class name ID
23166             * @param layoutUuid the layout uuid
23167             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23168             * @return the first matching journal article
23169             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23170             * @throws SystemException if a system exception occurred
23171             */
23172            @Override
23173            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
23174                    String layoutUuid, OrderByComparator orderByComparator)
23175                    throws NoSuchArticleException, SystemException {
23176                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
23177                                    classNameId, layoutUuid, orderByComparator);
23178    
23179                    if (journalArticle != null) {
23180                            return journalArticle;
23181                    }
23182    
23183                    StringBundler msg = new StringBundler(8);
23184    
23185                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23186    
23187                    msg.append("groupId=");
23188                    msg.append(groupId);
23189    
23190                    msg.append(", classNameId=");
23191                    msg.append(classNameId);
23192    
23193                    msg.append(", layoutUuid=");
23194                    msg.append(layoutUuid);
23195    
23196                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23197    
23198                    throw new NoSuchArticleException(msg.toString());
23199            }
23200    
23201            /**
23202             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23203             *
23204             * @param groupId the group ID
23205             * @param classNameId the class name ID
23206             * @param layoutUuid the layout uuid
23207             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23208             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23209             * @throws SystemException if a system exception occurred
23210             */
23211            @Override
23212            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
23213                    String layoutUuid, OrderByComparator orderByComparator)
23214                    throws SystemException {
23215                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
23216                                    layoutUuid, 0, 1, orderByComparator);
23217    
23218                    if (!list.isEmpty()) {
23219                            return list.get(0);
23220                    }
23221    
23222                    return null;
23223            }
23224    
23225            /**
23226             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23227             *
23228             * @param groupId the group ID
23229             * @param classNameId the class name ID
23230             * @param layoutUuid the layout uuid
23231             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23232             * @return the last matching journal article
23233             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23234             * @throws SystemException if a system exception occurred
23235             */
23236            @Override
23237            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
23238                    String layoutUuid, OrderByComparator orderByComparator)
23239                    throws NoSuchArticleException, SystemException {
23240                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
23241                                    layoutUuid, orderByComparator);
23242    
23243                    if (journalArticle != null) {
23244                            return journalArticle;
23245                    }
23246    
23247                    StringBundler msg = new StringBundler(8);
23248    
23249                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23250    
23251                    msg.append("groupId=");
23252                    msg.append(groupId);
23253    
23254                    msg.append(", classNameId=");
23255                    msg.append(classNameId);
23256    
23257                    msg.append(", layoutUuid=");
23258                    msg.append(layoutUuid);
23259    
23260                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23261    
23262                    throw new NoSuchArticleException(msg.toString());
23263            }
23264    
23265            /**
23266             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23267             *
23268             * @param groupId the group ID
23269             * @param classNameId the class name ID
23270             * @param layoutUuid the layout uuid
23271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23272             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23273             * @throws SystemException if a system exception occurred
23274             */
23275            @Override
23276            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
23277                    String layoutUuid, OrderByComparator orderByComparator)
23278                    throws SystemException {
23279                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
23280    
23281                    if (count == 0) {
23282                            return null;
23283                    }
23284    
23285                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
23286                                    layoutUuid, count - 1, count, orderByComparator);
23287    
23288                    if (!list.isEmpty()) {
23289                            return list.get(0);
23290                    }
23291    
23292                    return null;
23293            }
23294    
23295            /**
23296             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23297             *
23298             * @param id the primary key of the current journal article
23299             * @param groupId the group ID
23300             * @param classNameId the class name ID
23301             * @param layoutUuid the layout uuid
23302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23303             * @return the previous, current, and next journal article
23304             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23305             * @throws SystemException if a system exception occurred
23306             */
23307            @Override
23308            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
23309                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
23310                    throws NoSuchArticleException, SystemException {
23311                    JournalArticle journalArticle = findByPrimaryKey(id);
23312    
23313                    Session session = null;
23314    
23315                    try {
23316                            session = openSession();
23317    
23318                            JournalArticle[] array = new JournalArticleImpl[3];
23319    
23320                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
23321                                            classNameId, layoutUuid, orderByComparator, true);
23322    
23323                            array[1] = journalArticle;
23324    
23325                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
23326                                            classNameId, layoutUuid, orderByComparator, false);
23327    
23328                            return array;
23329                    }
23330                    catch (Exception e) {
23331                            throw processException(e);
23332                    }
23333                    finally {
23334                            closeSession(session);
23335                    }
23336            }
23337    
23338            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
23339                    JournalArticle journalArticle, long groupId, long classNameId,
23340                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
23341                    StringBundler query = null;
23342    
23343                    if (orderByComparator != null) {
23344                            query = new StringBundler(6 +
23345                                            (orderByComparator.getOrderByFields().length * 6));
23346                    }
23347                    else {
23348                            query = new StringBundler(3);
23349                    }
23350    
23351                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23352    
23353                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23354    
23355                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23356    
23357                    boolean bindLayoutUuid = false;
23358    
23359                    if (layoutUuid == null) {
23360                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23361                    }
23362                    else if (layoutUuid.equals(StringPool.BLANK)) {
23363                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23364                    }
23365                    else {
23366                            bindLayoutUuid = true;
23367    
23368                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23369                    }
23370    
23371                    if (orderByComparator != null) {
23372                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23373    
23374                            if (orderByConditionFields.length > 0) {
23375                                    query.append(WHERE_AND);
23376                            }
23377    
23378                            for (int i = 0; i < orderByConditionFields.length; i++) {
23379                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23380                                    query.append(orderByConditionFields[i]);
23381    
23382                                    if ((i + 1) < orderByConditionFields.length) {
23383                                            if (orderByComparator.isAscending() ^ previous) {
23384                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23385                                            }
23386                                            else {
23387                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23388                                            }
23389                                    }
23390                                    else {
23391                                            if (orderByComparator.isAscending() ^ previous) {
23392                                                    query.append(WHERE_GREATER_THAN);
23393                                            }
23394                                            else {
23395                                                    query.append(WHERE_LESSER_THAN);
23396                                            }
23397                                    }
23398                            }
23399    
23400                            query.append(ORDER_BY_CLAUSE);
23401    
23402                            String[] orderByFields = orderByComparator.getOrderByFields();
23403    
23404                            for (int i = 0; i < orderByFields.length; i++) {
23405                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23406                                    query.append(orderByFields[i]);
23407    
23408                                    if ((i + 1) < orderByFields.length) {
23409                                            if (orderByComparator.isAscending() ^ previous) {
23410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23411                                            }
23412                                            else {
23413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23414                                            }
23415                                    }
23416                                    else {
23417                                            if (orderByComparator.isAscending() ^ previous) {
23418                                                    query.append(ORDER_BY_ASC);
23419                                            }
23420                                            else {
23421                                                    query.append(ORDER_BY_DESC);
23422                                            }
23423                                    }
23424                            }
23425                    }
23426                    else {
23427                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23428                    }
23429    
23430                    String sql = query.toString();
23431    
23432                    Query q = session.createQuery(sql);
23433    
23434                    q.setFirstResult(0);
23435                    q.setMaxResults(2);
23436    
23437                    QueryPos qPos = QueryPos.getInstance(q);
23438    
23439                    qPos.add(groupId);
23440    
23441                    qPos.add(classNameId);
23442    
23443                    if (bindLayoutUuid) {
23444                            qPos.add(layoutUuid);
23445                    }
23446    
23447                    if (orderByComparator != null) {
23448                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23449    
23450                            for (Object value : values) {
23451                                    qPos.add(value);
23452                            }
23453                    }
23454    
23455                    List<JournalArticle> list = q.list();
23456    
23457                    if (list.size() == 2) {
23458                            return list.get(1);
23459                    }
23460                    else {
23461                            return null;
23462                    }
23463            }
23464    
23465            /**
23466             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23467             *
23468             * @param groupId the group ID
23469             * @param classNameId the class name ID
23470             * @param layoutUuid the layout uuid
23471             * @return the matching journal articles that the user has permission to view
23472             * @throws SystemException if a system exception occurred
23473             */
23474            @Override
23475            public List<JournalArticle> filterFindByG_C_L(long groupId,
23476                    long classNameId, String layoutUuid) throws SystemException {
23477                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
23478                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23479            }
23480    
23481            /**
23482             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23483             *
23484             * <p>
23485             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23486             * </p>
23487             *
23488             * @param groupId the group ID
23489             * @param classNameId the class name ID
23490             * @param layoutUuid the layout uuid
23491             * @param start the lower bound of the range of journal articles
23492             * @param end the upper bound of the range of journal articles (not inclusive)
23493             * @return the range of matching journal articles that the user has permission to view
23494             * @throws SystemException if a system exception occurred
23495             */
23496            @Override
23497            public List<JournalArticle> filterFindByG_C_L(long groupId,
23498                    long classNameId, String layoutUuid, int start, int end)
23499                    throws SystemException {
23500                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
23501                            null);
23502            }
23503    
23504            /**
23505             * 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;.
23506             *
23507             * <p>
23508             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23509             * </p>
23510             *
23511             * @param groupId the group ID
23512             * @param classNameId the class name ID
23513             * @param layoutUuid the layout uuid
23514             * @param start the lower bound of the range of journal articles
23515             * @param end the upper bound of the range of journal articles (not inclusive)
23516             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23517             * @return the ordered range of matching journal articles that the user has permission to view
23518             * @throws SystemException if a system exception occurred
23519             */
23520            @Override
23521            public List<JournalArticle> filterFindByG_C_L(long groupId,
23522                    long classNameId, String layoutUuid, int start, int end,
23523                    OrderByComparator orderByComparator) throws SystemException {
23524                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23525                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
23526                                    orderByComparator);
23527                    }
23528    
23529                    StringBundler query = null;
23530    
23531                    if (orderByComparator != null) {
23532                            query = new StringBundler(5 +
23533                                            (orderByComparator.getOrderByFields().length * 3));
23534                    }
23535                    else {
23536                            query = new StringBundler(5);
23537                    }
23538    
23539                    if (getDB().isSupportsInlineDistinct()) {
23540                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23541                    }
23542                    else {
23543                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23544                    }
23545    
23546                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23547    
23548                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23549    
23550                    boolean bindLayoutUuid = false;
23551    
23552                    if (layoutUuid == null) {
23553                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23554                    }
23555                    else if (layoutUuid.equals(StringPool.BLANK)) {
23556                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23557                    }
23558                    else {
23559                            bindLayoutUuid = true;
23560    
23561                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23562                    }
23563    
23564                    if (!getDB().isSupportsInlineDistinct()) {
23565                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23566                    }
23567    
23568                    if (orderByComparator != null) {
23569                            if (getDB().isSupportsInlineDistinct()) {
23570                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23571                                            orderByComparator, true);
23572                            }
23573                            else {
23574                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23575                                            orderByComparator, true);
23576                            }
23577                    }
23578                    else {
23579                            if (getDB().isSupportsInlineDistinct()) {
23580                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23581                            }
23582                            else {
23583                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23584                            }
23585                    }
23586    
23587                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23588                                    JournalArticle.class.getName(),
23589                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23590    
23591                    Session session = null;
23592    
23593                    try {
23594                            session = openSession();
23595    
23596                            SQLQuery q = session.createSQLQuery(sql);
23597    
23598                            if (getDB().isSupportsInlineDistinct()) {
23599                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23600                            }
23601                            else {
23602                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23603                            }
23604    
23605                            QueryPos qPos = QueryPos.getInstance(q);
23606    
23607                            qPos.add(groupId);
23608    
23609                            qPos.add(classNameId);
23610    
23611                            if (bindLayoutUuid) {
23612                                    qPos.add(layoutUuid);
23613                            }
23614    
23615                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23616                                    end);
23617                    }
23618                    catch (Exception e) {
23619                            throw processException(e);
23620                    }
23621                    finally {
23622                            closeSession(session);
23623                    }
23624            }
23625    
23626            /**
23627             * 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;.
23628             *
23629             * @param id the primary key of the current journal article
23630             * @param groupId the group ID
23631             * @param classNameId the class name ID
23632             * @param layoutUuid the layout uuid
23633             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23634             * @return the previous, current, and next journal article
23635             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23636             * @throws SystemException if a system exception occurred
23637             */
23638            @Override
23639            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
23640                    long groupId, long classNameId, String layoutUuid,
23641                    OrderByComparator orderByComparator)
23642                    throws NoSuchArticleException, SystemException {
23643                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23644                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
23645                                    layoutUuid, orderByComparator);
23646                    }
23647    
23648                    JournalArticle journalArticle = findByPrimaryKey(id);
23649    
23650                    Session session = null;
23651    
23652                    try {
23653                            session = openSession();
23654    
23655                            JournalArticle[] array = new JournalArticleImpl[3];
23656    
23657                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
23658                                            groupId, classNameId, layoutUuid, orderByComparator, true);
23659    
23660                            array[1] = journalArticle;
23661    
23662                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
23663                                            groupId, classNameId, layoutUuid, orderByComparator, false);
23664    
23665                            return array;
23666                    }
23667                    catch (Exception e) {
23668                            throw processException(e);
23669                    }
23670                    finally {
23671                            closeSession(session);
23672                    }
23673            }
23674    
23675            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
23676                    JournalArticle journalArticle, long groupId, long classNameId,
23677                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
23678                    StringBundler query = null;
23679    
23680                    if (orderByComparator != null) {
23681                            query = new StringBundler(6 +
23682                                            (orderByComparator.getOrderByFields().length * 6));
23683                    }
23684                    else {
23685                            query = new StringBundler(3);
23686                    }
23687    
23688                    if (getDB().isSupportsInlineDistinct()) {
23689                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23690                    }
23691                    else {
23692                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23693                    }
23694    
23695                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23696    
23697                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23698    
23699                    boolean bindLayoutUuid = false;
23700    
23701                    if (layoutUuid == null) {
23702                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23703                    }
23704                    else if (layoutUuid.equals(StringPool.BLANK)) {
23705                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23706                    }
23707                    else {
23708                            bindLayoutUuid = true;
23709    
23710                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23711                    }
23712    
23713                    if (!getDB().isSupportsInlineDistinct()) {
23714                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23715                    }
23716    
23717                    if (orderByComparator != null) {
23718                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23719    
23720                            if (orderByConditionFields.length > 0) {
23721                                    query.append(WHERE_AND);
23722                            }
23723    
23724                            for (int i = 0; i < orderByConditionFields.length; i++) {
23725                                    if (getDB().isSupportsInlineDistinct()) {
23726                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23727                                    }
23728                                    else {
23729                                            query.append(_ORDER_BY_ENTITY_TABLE);
23730                                    }
23731    
23732                                    query.append(orderByConditionFields[i]);
23733    
23734                                    if ((i + 1) < orderByConditionFields.length) {
23735                                            if (orderByComparator.isAscending() ^ previous) {
23736                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23737                                            }
23738                                            else {
23739                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23740                                            }
23741                                    }
23742                                    else {
23743                                            if (orderByComparator.isAscending() ^ previous) {
23744                                                    query.append(WHERE_GREATER_THAN);
23745                                            }
23746                                            else {
23747                                                    query.append(WHERE_LESSER_THAN);
23748                                            }
23749                                    }
23750                            }
23751    
23752                            query.append(ORDER_BY_CLAUSE);
23753    
23754                            String[] orderByFields = orderByComparator.getOrderByFields();
23755    
23756                            for (int i = 0; i < orderByFields.length; i++) {
23757                                    if (getDB().isSupportsInlineDistinct()) {
23758                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23759                                    }
23760                                    else {
23761                                            query.append(_ORDER_BY_ENTITY_TABLE);
23762                                    }
23763    
23764                                    query.append(orderByFields[i]);
23765    
23766                                    if ((i + 1) < orderByFields.length) {
23767                                            if (orderByComparator.isAscending() ^ previous) {
23768                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23769                                            }
23770                                            else {
23771                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23772                                            }
23773                                    }
23774                                    else {
23775                                            if (orderByComparator.isAscending() ^ previous) {
23776                                                    query.append(ORDER_BY_ASC);
23777                                            }
23778                                            else {
23779                                                    query.append(ORDER_BY_DESC);
23780                                            }
23781                                    }
23782                            }
23783                    }
23784                    else {
23785                            if (getDB().isSupportsInlineDistinct()) {
23786                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23787                            }
23788                            else {
23789                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23790                            }
23791                    }
23792    
23793                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23794                                    JournalArticle.class.getName(),
23795                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23796    
23797                    SQLQuery q = session.createSQLQuery(sql);
23798    
23799                    q.setFirstResult(0);
23800                    q.setMaxResults(2);
23801    
23802                    if (getDB().isSupportsInlineDistinct()) {
23803                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23804                    }
23805                    else {
23806                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23807                    }
23808    
23809                    QueryPos qPos = QueryPos.getInstance(q);
23810    
23811                    qPos.add(groupId);
23812    
23813                    qPos.add(classNameId);
23814    
23815                    if (bindLayoutUuid) {
23816                            qPos.add(layoutUuid);
23817                    }
23818    
23819                    if (orderByComparator != null) {
23820                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23821    
23822                            for (Object value : values) {
23823                                    qPos.add(value);
23824                            }
23825                    }
23826    
23827                    List<JournalArticle> list = q.list();
23828    
23829                    if (list.size() == 2) {
23830                            return list.get(1);
23831                    }
23832                    else {
23833                            return null;
23834                    }
23835            }
23836    
23837            /**
23838             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
23839             *
23840             * @param groupId the group ID
23841             * @param classNameId the class name ID
23842             * @param layoutUuid the layout uuid
23843             * @throws SystemException if a system exception occurred
23844             */
23845            @Override
23846            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
23847                    throws SystemException {
23848                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
23849                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23850                            remove(journalArticle);
23851                    }
23852            }
23853    
23854            /**
23855             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23856             *
23857             * @param groupId the group ID
23858             * @param classNameId the class name ID
23859             * @param layoutUuid the layout uuid
23860             * @return the number of matching journal articles
23861             * @throws SystemException if a system exception occurred
23862             */
23863            @Override
23864            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
23865                    throws SystemException {
23866                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
23867    
23868                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
23869    
23870                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23871                                    this);
23872    
23873                    if (count == null) {
23874                            StringBundler query = new StringBundler(4);
23875    
23876                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23877    
23878                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23879    
23880                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23881    
23882                            boolean bindLayoutUuid = false;
23883    
23884                            if (layoutUuid == null) {
23885                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23886                            }
23887                            else if (layoutUuid.equals(StringPool.BLANK)) {
23888                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23889                            }
23890                            else {
23891                                    bindLayoutUuid = true;
23892    
23893                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23894                            }
23895    
23896                            String sql = query.toString();
23897    
23898                            Session session = null;
23899    
23900                            try {
23901                                    session = openSession();
23902    
23903                                    Query q = session.createQuery(sql);
23904    
23905                                    QueryPos qPos = QueryPos.getInstance(q);
23906    
23907                                    qPos.add(groupId);
23908    
23909                                    qPos.add(classNameId);
23910    
23911                                    if (bindLayoutUuid) {
23912                                            qPos.add(layoutUuid);
23913                                    }
23914    
23915                                    count = (Long)q.uniqueResult();
23916    
23917                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23918                            }
23919                            catch (Exception e) {
23920                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23921    
23922                                    throw processException(e);
23923                            }
23924                            finally {
23925                                    closeSession(session);
23926                            }
23927                    }
23928    
23929                    return count.intValue();
23930            }
23931    
23932            /**
23933             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23934             *
23935             * @param groupId the group ID
23936             * @param classNameId the class name ID
23937             * @param layoutUuid the layout uuid
23938             * @return the number of matching journal articles that the user has permission to view
23939             * @throws SystemException if a system exception occurred
23940             */
23941            @Override
23942            public int filterCountByG_C_L(long groupId, long classNameId,
23943                    String layoutUuid) throws SystemException {
23944                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23945                            return countByG_C_L(groupId, classNameId, layoutUuid);
23946                    }
23947    
23948                    StringBundler query = new StringBundler(4);
23949    
23950                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23951    
23952                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23953    
23954                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23955    
23956                    boolean bindLayoutUuid = false;
23957    
23958                    if (layoutUuid == null) {
23959                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23960                    }
23961                    else if (layoutUuid.equals(StringPool.BLANK)) {
23962                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23963                    }
23964                    else {
23965                            bindLayoutUuid = true;
23966    
23967                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23968                    }
23969    
23970                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23971                                    JournalArticle.class.getName(),
23972                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23973    
23974                    Session session = null;
23975    
23976                    try {
23977                            session = openSession();
23978    
23979                            SQLQuery q = session.createSQLQuery(sql);
23980    
23981                            q.addScalar(COUNT_COLUMN_NAME,
23982                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
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                            Long count = (Long)q.uniqueResult();
23995    
23996                            return count.intValue();
23997                    }
23998                    catch (Exception e) {
23999                            throw processException(e);
24000                    }
24001                    finally {
24002                            closeSession(session);
24003                    }
24004            }
24005    
24006            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
24007            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24008            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24009            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24010            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
24011            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24012                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24013                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
24014                            new String[] {
24015                                    Long.class.getName(), String.class.getName(),
24016                                    Double.class.getName()
24017                            },
24018                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24019                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24020                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24021            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24022                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24023                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
24024                            new String[] {
24025                                    Long.class.getName(), String.class.getName(),
24026                                    Double.class.getName()
24027                            });
24028    
24029            /**
24030             * 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.
24031             *
24032             * @param groupId the group ID
24033             * @param articleId the article ID
24034             * @param version the version
24035             * @return the matching journal article
24036             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24037             * @throws SystemException if a system exception occurred
24038             */
24039            @Override
24040            public JournalArticle findByG_A_V(long groupId, String articleId,
24041                    double version) throws NoSuchArticleException, SystemException {
24042                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
24043    
24044                    if (journalArticle == null) {
24045                            StringBundler msg = new StringBundler(8);
24046    
24047                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24048    
24049                            msg.append("groupId=");
24050                            msg.append(groupId);
24051    
24052                            msg.append(", articleId=");
24053                            msg.append(articleId);
24054    
24055                            msg.append(", version=");
24056                            msg.append(version);
24057    
24058                            msg.append(StringPool.CLOSE_CURLY_BRACE);
24059    
24060                            if (_log.isWarnEnabled()) {
24061                                    _log.warn(msg.toString());
24062                            }
24063    
24064                            throw new NoSuchArticleException(msg.toString());
24065                    }
24066    
24067                    return journalArticle;
24068            }
24069    
24070            /**
24071             * 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.
24072             *
24073             * @param groupId the group ID
24074             * @param articleId the article ID
24075             * @param version the version
24076             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24077             * @throws SystemException if a system exception occurred
24078             */
24079            @Override
24080            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24081                    double version) throws SystemException {
24082                    return fetchByG_A_V(groupId, articleId, version, true);
24083            }
24084    
24085            /**
24086             * 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.
24087             *
24088             * @param groupId the group ID
24089             * @param articleId the article ID
24090             * @param version the version
24091             * @param retrieveFromCache whether to use the finder cache
24092             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24093             * @throws SystemException if a system exception occurred
24094             */
24095            @Override
24096            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24097                    double version, boolean retrieveFromCache) throws SystemException {
24098                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24099    
24100                    Object result = null;
24101    
24102                    if (retrieveFromCache) {
24103                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
24104                                            finderArgs, this);
24105                    }
24106    
24107                    if (result instanceof JournalArticle) {
24108                            JournalArticle journalArticle = (JournalArticle)result;
24109    
24110                            if ((groupId != journalArticle.getGroupId()) ||
24111                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
24112                                            (version != journalArticle.getVersion())) {
24113                                    result = null;
24114                            }
24115                    }
24116    
24117                    if (result == null) {
24118                            StringBundler query = new StringBundler(5);
24119    
24120                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24121    
24122                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24123    
24124                            boolean bindArticleId = false;
24125    
24126                            if (articleId == null) {
24127                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24128                            }
24129                            else if (articleId.equals(StringPool.BLANK)) {
24130                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24131                            }
24132                            else {
24133                                    bindArticleId = true;
24134    
24135                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24136                            }
24137    
24138                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
24139    
24140                            String sql = query.toString();
24141    
24142                            Session session = null;
24143    
24144                            try {
24145                                    session = openSession();
24146    
24147                                    Query q = session.createQuery(sql);
24148    
24149                                    QueryPos qPos = QueryPos.getInstance(q);
24150    
24151                                    qPos.add(groupId);
24152    
24153                                    if (bindArticleId) {
24154                                            qPos.add(articleId);
24155                                    }
24156    
24157                                    qPos.add(version);
24158    
24159                                    List<JournalArticle> list = q.list();
24160    
24161                                    if (list.isEmpty()) {
24162                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24163                                                    finderArgs, list);
24164                                    }
24165                                    else {
24166                                            JournalArticle journalArticle = list.get(0);
24167    
24168                                            result = journalArticle;
24169    
24170                                            cacheResult(journalArticle);
24171    
24172                                            if ((journalArticle.getGroupId() != groupId) ||
24173                                                            (journalArticle.getArticleId() == null) ||
24174                                                            !journalArticle.getArticleId().equals(articleId) ||
24175                                                            (journalArticle.getVersion() != version)) {
24176                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24177                                                            finderArgs, journalArticle);
24178                                            }
24179                                    }
24180                            }
24181                            catch (Exception e) {
24182                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
24183                                            finderArgs);
24184    
24185                                    throw processException(e);
24186                            }
24187                            finally {
24188                                    closeSession(session);
24189                            }
24190                    }
24191    
24192                    if (result instanceof List<?>) {
24193                            return null;
24194                    }
24195                    else {
24196                            return (JournalArticle)result;
24197                    }
24198            }
24199    
24200            /**
24201             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
24202             *
24203             * @param groupId the group ID
24204             * @param articleId the article ID
24205             * @param version the version
24206             * @return the journal article that was removed
24207             * @throws SystemException if a system exception occurred
24208             */
24209            @Override
24210            public JournalArticle removeByG_A_V(long groupId, String articleId,
24211                    double version) throws NoSuchArticleException, SystemException {
24212                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
24213    
24214                    return remove(journalArticle);
24215            }
24216    
24217            /**
24218             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
24219             *
24220             * @param groupId the group ID
24221             * @param articleId the article ID
24222             * @param version the version
24223             * @return the number of matching journal articles
24224             * @throws SystemException if a system exception occurred
24225             */
24226            @Override
24227            public int countByG_A_V(long groupId, String articleId, double version)
24228                    throws SystemException {
24229                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
24230    
24231                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24232    
24233                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24234                                    this);
24235    
24236                    if (count == null) {
24237                            StringBundler query = new StringBundler(4);
24238    
24239                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24240    
24241                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24242    
24243                            boolean bindArticleId = false;
24244    
24245                            if (articleId == null) {
24246                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24247                            }
24248                            else if (articleId.equals(StringPool.BLANK)) {
24249                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24250                            }
24251                            else {
24252                                    bindArticleId = true;
24253    
24254                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24255                            }
24256    
24257                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
24258    
24259                            String sql = query.toString();
24260    
24261                            Session session = null;
24262    
24263                            try {
24264                                    session = openSession();
24265    
24266                                    Query q = session.createQuery(sql);
24267    
24268                                    QueryPos qPos = QueryPos.getInstance(q);
24269    
24270                                    qPos.add(groupId);
24271    
24272                                    if (bindArticleId) {
24273                                            qPos.add(articleId);
24274                                    }
24275    
24276                                    qPos.add(version);
24277    
24278                                    count = (Long)q.uniqueResult();
24279    
24280                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24281                            }
24282                            catch (Exception e) {
24283                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24284    
24285                                    throw processException(e);
24286                            }
24287                            finally {
24288                                    closeSession(session);
24289                            }
24290                    }
24291    
24292                    return count.intValue();
24293            }
24294    
24295            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
24296            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
24297            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
24298            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
24299            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
24300            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24301                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24302                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
24303                            "findByG_A_ST",
24304                            new String[] {
24305                                    Long.class.getName(), String.class.getName(),
24306                                    Integer.class.getName(),
24307                                    
24308                            Integer.class.getName(), Integer.class.getName(),
24309                                    OrderByComparator.class.getName()
24310                            });
24311            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
24312                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24313                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24314                            JournalArticleImpl.class,
24315                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
24316                            new String[] {
24317                                    Long.class.getName(), String.class.getName(),
24318                                    Integer.class.getName()
24319                            },
24320                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24321                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24322                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
24323                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24324            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24325                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24326                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
24327                            new String[] {
24328                                    Long.class.getName(), String.class.getName(),
24329                                    Integer.class.getName()
24330                            });
24331            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24332                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24333                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
24334                            new String[] {
24335                                    Long.class.getName(), String.class.getName(),
24336                                    Integer.class.getName()
24337                            });
24338    
24339            /**
24340             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24341             *
24342             * @param groupId the group ID
24343             * @param articleId the article ID
24344             * @param status the status
24345             * @return the matching journal articles
24346             * @throws SystemException if a system exception occurred
24347             */
24348            @Override
24349            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24350                    int status) throws SystemException {
24351                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
24352                            QueryUtil.ALL_POS, null);
24353            }
24354    
24355            /**
24356             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24357             *
24358             * <p>
24359             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24360             * </p>
24361             *
24362             * @param groupId the group ID
24363             * @param articleId the article ID
24364             * @param status the status
24365             * @param start the lower bound of the range of journal articles
24366             * @param end the upper bound of the range of journal articles (not inclusive)
24367             * @return the range of matching journal articles
24368             * @throws SystemException if a system exception occurred
24369             */
24370            @Override
24371            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24372                    int status, int start, int end) throws SystemException {
24373                    return findByG_A_ST(groupId, articleId, status, start, end, null);
24374            }
24375    
24376            /**
24377             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24378             *
24379             * <p>
24380             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24381             * </p>
24382             *
24383             * @param groupId the group ID
24384             * @param articleId the article ID
24385             * @param status the status
24386             * @param start the lower bound of the range of journal articles
24387             * @param end the upper bound of the range of journal articles (not inclusive)
24388             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24389             * @return the ordered range of matching journal articles
24390             * @throws SystemException if a system exception occurred
24391             */
24392            @Override
24393            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24394                    int status, int start, int end, OrderByComparator orderByComparator)
24395                    throws SystemException {
24396                    boolean pagination = true;
24397                    FinderPath finderPath = null;
24398                    Object[] finderArgs = null;
24399    
24400                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24401                                    (orderByComparator == null)) {
24402                            pagination = false;
24403                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
24404                            finderArgs = new Object[] { groupId, articleId, status };
24405                    }
24406                    else {
24407                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
24408                            finderArgs = new Object[] {
24409                                            groupId, articleId, status,
24410                                            
24411                                            start, end, orderByComparator
24412                                    };
24413                    }
24414    
24415                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
24416                                    finderArgs, this);
24417    
24418                    if ((list != null) && !list.isEmpty()) {
24419                            for (JournalArticle journalArticle : list) {
24420                                    if ((groupId != journalArticle.getGroupId()) ||
24421                                                    !Validator.equals(articleId,
24422                                                            journalArticle.getArticleId()) ||
24423                                                    (status != journalArticle.getStatus())) {
24424                                            list = null;
24425    
24426                                            break;
24427                                    }
24428                            }
24429                    }
24430    
24431                    if (list == null) {
24432                            StringBundler query = null;
24433    
24434                            if (orderByComparator != null) {
24435                                    query = new StringBundler(5 +
24436                                                    (orderByComparator.getOrderByFields().length * 3));
24437                            }
24438                            else {
24439                                    query = new StringBundler(5);
24440                            }
24441    
24442                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24443    
24444                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24445    
24446                            boolean bindArticleId = false;
24447    
24448                            if (articleId == null) {
24449                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24450                            }
24451                            else if (articleId.equals(StringPool.BLANK)) {
24452                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24453                            }
24454                            else {
24455                                    bindArticleId = true;
24456    
24457                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24458                            }
24459    
24460                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24461    
24462                            if (orderByComparator != null) {
24463                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24464                                            orderByComparator);
24465                            }
24466                            else
24467                             if (pagination) {
24468                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24469                            }
24470    
24471                            String sql = query.toString();
24472    
24473                            Session session = null;
24474    
24475                            try {
24476                                    session = openSession();
24477    
24478                                    Query q = session.createQuery(sql);
24479    
24480                                    QueryPos qPos = QueryPos.getInstance(q);
24481    
24482                                    qPos.add(groupId);
24483    
24484                                    if (bindArticleId) {
24485                                            qPos.add(articleId);
24486                                    }
24487    
24488                                    qPos.add(status);
24489    
24490                                    if (!pagination) {
24491                                            list = (List<JournalArticle>)QueryUtil.list(q,
24492                                                            getDialect(), start, end, false);
24493    
24494                                            Collections.sort(list);
24495    
24496                                            list = new UnmodifiableList<JournalArticle>(list);
24497                                    }
24498                                    else {
24499                                            list = (List<JournalArticle>)QueryUtil.list(q,
24500                                                            getDialect(), start, end);
24501                                    }
24502    
24503                                    cacheResult(list);
24504    
24505                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24506                            }
24507                            catch (Exception e) {
24508                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24509    
24510                                    throw processException(e);
24511                            }
24512                            finally {
24513                                    closeSession(session);
24514                            }
24515                    }
24516    
24517                    return list;
24518            }
24519    
24520            /**
24521             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24522             *
24523             * @param groupId the group ID
24524             * @param articleId the article ID
24525             * @param status the status
24526             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24527             * @return the first matching journal article
24528             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24529             * @throws SystemException if a system exception occurred
24530             */
24531            @Override
24532            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
24533                    int status, OrderByComparator orderByComparator)
24534                    throws NoSuchArticleException, SystemException {
24535                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
24536                                    status, orderByComparator);
24537    
24538                    if (journalArticle != null) {
24539                            return journalArticle;
24540                    }
24541    
24542                    StringBundler msg = new StringBundler(8);
24543    
24544                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24545    
24546                    msg.append("groupId=");
24547                    msg.append(groupId);
24548    
24549                    msg.append(", articleId=");
24550                    msg.append(articleId);
24551    
24552                    msg.append(", status=");
24553                    msg.append(status);
24554    
24555                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24556    
24557                    throw new NoSuchArticleException(msg.toString());
24558            }
24559    
24560            /**
24561             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24562             *
24563             * @param groupId the group ID
24564             * @param articleId the article ID
24565             * @param status the status
24566             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24567             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24568             * @throws SystemException if a system exception occurred
24569             */
24570            @Override
24571            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
24572                    int status, OrderByComparator orderByComparator)
24573                    throws SystemException {
24574                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
24575                                    1, orderByComparator);
24576    
24577                    if (!list.isEmpty()) {
24578                            return list.get(0);
24579                    }
24580    
24581                    return null;
24582            }
24583    
24584            /**
24585             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24586             *
24587             * @param groupId the group ID
24588             * @param articleId the article ID
24589             * @param status the status
24590             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24591             * @return the last matching journal article
24592             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24593             * @throws SystemException if a system exception occurred
24594             */
24595            @Override
24596            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
24597                    int status, OrderByComparator orderByComparator)
24598                    throws NoSuchArticleException, SystemException {
24599                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
24600                                    status, orderByComparator);
24601    
24602                    if (journalArticle != null) {
24603                            return journalArticle;
24604                    }
24605    
24606                    StringBundler msg = new StringBundler(8);
24607    
24608                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24609    
24610                    msg.append("groupId=");
24611                    msg.append(groupId);
24612    
24613                    msg.append(", articleId=");
24614                    msg.append(articleId);
24615    
24616                    msg.append(", status=");
24617                    msg.append(status);
24618    
24619                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24620    
24621                    throw new NoSuchArticleException(msg.toString());
24622            }
24623    
24624            /**
24625             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24626             *
24627             * @param groupId the group ID
24628             * @param articleId the article ID
24629             * @param status the status
24630             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24631             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24632             * @throws SystemException if a system exception occurred
24633             */
24634            @Override
24635            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
24636                    int status, OrderByComparator orderByComparator)
24637                    throws SystemException {
24638                    int count = countByG_A_ST(groupId, articleId, status);
24639    
24640                    if (count == 0) {
24641                            return null;
24642                    }
24643    
24644                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
24645                                    count - 1, count, orderByComparator);
24646    
24647                    if (!list.isEmpty()) {
24648                            return list.get(0);
24649                    }
24650    
24651                    return null;
24652            }
24653    
24654            /**
24655             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24656             *
24657             * @param id the primary key of the current journal article
24658             * @param groupId the group ID
24659             * @param articleId the article ID
24660             * @param status the status
24661             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24662             * @return the previous, current, and next journal article
24663             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24664             * @throws SystemException if a system exception occurred
24665             */
24666            @Override
24667            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
24668                    String articleId, int status, OrderByComparator orderByComparator)
24669                    throws NoSuchArticleException, SystemException {
24670                    JournalArticle journalArticle = findByPrimaryKey(id);
24671    
24672                    Session session = null;
24673    
24674                    try {
24675                            session = openSession();
24676    
24677                            JournalArticle[] array = new JournalArticleImpl[3];
24678    
24679                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
24680                                            groupId, articleId, status, orderByComparator, true);
24681    
24682                            array[1] = journalArticle;
24683    
24684                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
24685                                            groupId, articleId, status, orderByComparator, false);
24686    
24687                            return array;
24688                    }
24689                    catch (Exception e) {
24690                            throw processException(e);
24691                    }
24692                    finally {
24693                            closeSession(session);
24694                    }
24695            }
24696    
24697            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
24698                    JournalArticle journalArticle, long groupId, String articleId,
24699                    int status, OrderByComparator orderByComparator, boolean previous) {
24700                    StringBundler query = null;
24701    
24702                    if (orderByComparator != null) {
24703                            query = new StringBundler(6 +
24704                                            (orderByComparator.getOrderByFields().length * 6));
24705                    }
24706                    else {
24707                            query = new StringBundler(3);
24708                    }
24709    
24710                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24711    
24712                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24713    
24714                    boolean bindArticleId = false;
24715    
24716                    if (articleId == null) {
24717                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24718                    }
24719                    else if (articleId.equals(StringPool.BLANK)) {
24720                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24721                    }
24722                    else {
24723                            bindArticleId = true;
24724    
24725                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24726                    }
24727    
24728                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24729    
24730                    if (orderByComparator != null) {
24731                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24732    
24733                            if (orderByConditionFields.length > 0) {
24734                                    query.append(WHERE_AND);
24735                            }
24736    
24737                            for (int i = 0; i < orderByConditionFields.length; i++) {
24738                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24739                                    query.append(orderByConditionFields[i]);
24740    
24741                                    if ((i + 1) < orderByConditionFields.length) {
24742                                            if (orderByComparator.isAscending() ^ previous) {
24743                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24744                                            }
24745                                            else {
24746                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24747                                            }
24748                                    }
24749                                    else {
24750                                            if (orderByComparator.isAscending() ^ previous) {
24751                                                    query.append(WHERE_GREATER_THAN);
24752                                            }
24753                                            else {
24754                                                    query.append(WHERE_LESSER_THAN);
24755                                            }
24756                                    }
24757                            }
24758    
24759                            query.append(ORDER_BY_CLAUSE);
24760    
24761                            String[] orderByFields = orderByComparator.getOrderByFields();
24762    
24763                            for (int i = 0; i < orderByFields.length; i++) {
24764                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24765                                    query.append(orderByFields[i]);
24766    
24767                                    if ((i + 1) < orderByFields.length) {
24768                                            if (orderByComparator.isAscending() ^ previous) {
24769                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24770                                            }
24771                                            else {
24772                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24773                                            }
24774                                    }
24775                                    else {
24776                                            if (orderByComparator.isAscending() ^ previous) {
24777                                                    query.append(ORDER_BY_ASC);
24778                                            }
24779                                            else {
24780                                                    query.append(ORDER_BY_DESC);
24781                                            }
24782                                    }
24783                            }
24784                    }
24785                    else {
24786                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24787                    }
24788    
24789                    String sql = query.toString();
24790    
24791                    Query q = session.createQuery(sql);
24792    
24793                    q.setFirstResult(0);
24794                    q.setMaxResults(2);
24795    
24796                    QueryPos qPos = QueryPos.getInstance(q);
24797    
24798                    qPos.add(groupId);
24799    
24800                    if (bindArticleId) {
24801                            qPos.add(articleId);
24802                    }
24803    
24804                    qPos.add(status);
24805    
24806                    if (orderByComparator != null) {
24807                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24808    
24809                            for (Object value : values) {
24810                                    qPos.add(value);
24811                            }
24812                    }
24813    
24814                    List<JournalArticle> list = q.list();
24815    
24816                    if (list.size() == 2) {
24817                            return list.get(1);
24818                    }
24819                    else {
24820                            return null;
24821                    }
24822            }
24823    
24824            /**
24825             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
24826             *
24827             * @param groupId the group ID
24828             * @param articleId the article ID
24829             * @param status the status
24830             * @return the matching journal articles that the user has permission to view
24831             * @throws SystemException if a system exception occurred
24832             */
24833            @Override
24834            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24835                    String articleId, int status) throws SystemException {
24836                    return filterFindByG_A_ST(groupId, articleId, status,
24837                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24838            }
24839    
24840            /**
24841             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
24842             *
24843             * <p>
24844             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24845             * </p>
24846             *
24847             * @param groupId the group ID
24848             * @param articleId the article ID
24849             * @param status the status
24850             * @param start the lower bound of the range of journal articles
24851             * @param end the upper bound of the range of journal articles (not inclusive)
24852             * @return the range of matching journal articles that the user has permission to view
24853             * @throws SystemException if a system exception occurred
24854             */
24855            @Override
24856            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24857                    String articleId, int status, int start, int end)
24858                    throws SystemException {
24859                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
24860            }
24861    
24862            /**
24863             * 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;.
24864             *
24865             * <p>
24866             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24867             * </p>
24868             *
24869             * @param groupId the group ID
24870             * @param articleId the article ID
24871             * @param status the status
24872             * @param start the lower bound of the range of journal articles
24873             * @param end the upper bound of the range of journal articles (not inclusive)
24874             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24875             * @return the ordered range of matching journal articles that the user has permission to view
24876             * @throws SystemException if a system exception occurred
24877             */
24878            @Override
24879            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24880                    String articleId, int status, int start, int end,
24881                    OrderByComparator orderByComparator) throws SystemException {
24882                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24883                            return findByG_A_ST(groupId, articleId, status, start, end,
24884                                    orderByComparator);
24885                    }
24886    
24887                    StringBundler query = null;
24888    
24889                    if (orderByComparator != null) {
24890                            query = new StringBundler(5 +
24891                                            (orderByComparator.getOrderByFields().length * 3));
24892                    }
24893                    else {
24894                            query = new StringBundler(5);
24895                    }
24896    
24897                    if (getDB().isSupportsInlineDistinct()) {
24898                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24899                    }
24900                    else {
24901                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24902                    }
24903    
24904                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24905    
24906                    boolean bindArticleId = false;
24907    
24908                    if (articleId == null) {
24909                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24910                    }
24911                    else if (articleId.equals(StringPool.BLANK)) {
24912                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24913                    }
24914                    else {
24915                            bindArticleId = true;
24916    
24917                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24918                    }
24919    
24920                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24921    
24922                    if (!getDB().isSupportsInlineDistinct()) {
24923                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24924                    }
24925    
24926                    if (orderByComparator != null) {
24927                            if (getDB().isSupportsInlineDistinct()) {
24928                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24929                                            orderByComparator, true);
24930                            }
24931                            else {
24932                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24933                                            orderByComparator, true);
24934                            }
24935                    }
24936                    else {
24937                            if (getDB().isSupportsInlineDistinct()) {
24938                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24939                            }
24940                            else {
24941                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24942                            }
24943                    }
24944    
24945                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24946                                    JournalArticle.class.getName(),
24947                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24948    
24949                    Session session = null;
24950    
24951                    try {
24952                            session = openSession();
24953    
24954                            SQLQuery q = session.createSQLQuery(sql);
24955    
24956                            if (getDB().isSupportsInlineDistinct()) {
24957                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24958                            }
24959                            else {
24960                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24961                            }
24962    
24963                            QueryPos qPos = QueryPos.getInstance(q);
24964    
24965                            qPos.add(groupId);
24966    
24967                            if (bindArticleId) {
24968                                    qPos.add(articleId);
24969                            }
24970    
24971                            qPos.add(status);
24972    
24973                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24974                                    end);
24975                    }
24976                    catch (Exception e) {
24977                            throw processException(e);
24978                    }
24979                    finally {
24980                            closeSession(session);
24981                    }
24982            }
24983    
24984            /**
24985             * 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;.
24986             *
24987             * @param id the primary key of the current journal article
24988             * @param groupId the group ID
24989             * @param articleId the article ID
24990             * @param status the status
24991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24992             * @return the previous, current, and next journal article
24993             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24994             * @throws SystemException if a system exception occurred
24995             */
24996            @Override
24997            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
24998                    long groupId, String articleId, int status,
24999                    OrderByComparator orderByComparator)
25000                    throws NoSuchArticleException, SystemException {
25001                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25002                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
25003                                    orderByComparator);
25004                    }
25005    
25006                    JournalArticle journalArticle = findByPrimaryKey(id);
25007    
25008                    Session session = null;
25009    
25010                    try {
25011                            session = openSession();
25012    
25013                            JournalArticle[] array = new JournalArticleImpl[3];
25014    
25015                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25016                                            groupId, articleId, status, orderByComparator, true);
25017    
25018                            array[1] = journalArticle;
25019    
25020                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25021                                            groupId, articleId, status, orderByComparator, false);
25022    
25023                            return array;
25024                    }
25025                    catch (Exception e) {
25026                            throw processException(e);
25027                    }
25028                    finally {
25029                            closeSession(session);
25030                    }
25031            }
25032    
25033            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
25034                    JournalArticle journalArticle, long groupId, String articleId,
25035                    int status, OrderByComparator orderByComparator, boolean previous) {
25036                    StringBundler query = null;
25037    
25038                    if (orderByComparator != null) {
25039                            query = new StringBundler(6 +
25040                                            (orderByComparator.getOrderByFields().length * 6));
25041                    }
25042                    else {
25043                            query = new StringBundler(3);
25044                    }
25045    
25046                    if (getDB().isSupportsInlineDistinct()) {
25047                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25048                    }
25049                    else {
25050                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25051                    }
25052    
25053                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25054    
25055                    boolean bindArticleId = false;
25056    
25057                    if (articleId == null) {
25058                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25059                    }
25060                    else if (articleId.equals(StringPool.BLANK)) {
25061                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25062                    }
25063                    else {
25064                            bindArticleId = true;
25065    
25066                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25067                    }
25068    
25069                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25070    
25071                    if (!getDB().isSupportsInlineDistinct()) {
25072                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25073                    }
25074    
25075                    if (orderByComparator != null) {
25076                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25077    
25078                            if (orderByConditionFields.length > 0) {
25079                                    query.append(WHERE_AND);
25080                            }
25081    
25082                            for (int i = 0; i < orderByConditionFields.length; i++) {
25083                                    if (getDB().isSupportsInlineDistinct()) {
25084                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25085                                    }
25086                                    else {
25087                                            query.append(_ORDER_BY_ENTITY_TABLE);
25088                                    }
25089    
25090                                    query.append(orderByConditionFields[i]);
25091    
25092                                    if ((i + 1) < orderByConditionFields.length) {
25093                                            if (orderByComparator.isAscending() ^ previous) {
25094                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25095                                            }
25096                                            else {
25097                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25098                                            }
25099                                    }
25100                                    else {
25101                                            if (orderByComparator.isAscending() ^ previous) {
25102                                                    query.append(WHERE_GREATER_THAN);
25103                                            }
25104                                            else {
25105                                                    query.append(WHERE_LESSER_THAN);
25106                                            }
25107                                    }
25108                            }
25109    
25110                            query.append(ORDER_BY_CLAUSE);
25111    
25112                            String[] orderByFields = orderByComparator.getOrderByFields();
25113    
25114                            for (int i = 0; i < orderByFields.length; i++) {
25115                                    if (getDB().isSupportsInlineDistinct()) {
25116                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25117                                    }
25118                                    else {
25119                                            query.append(_ORDER_BY_ENTITY_TABLE);
25120                                    }
25121    
25122                                    query.append(orderByFields[i]);
25123    
25124                                    if ((i + 1) < orderByFields.length) {
25125                                            if (orderByComparator.isAscending() ^ previous) {
25126                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25127                                            }
25128                                            else {
25129                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25130                                            }
25131                                    }
25132                                    else {
25133                                            if (orderByComparator.isAscending() ^ previous) {
25134                                                    query.append(ORDER_BY_ASC);
25135                                            }
25136                                            else {
25137                                                    query.append(ORDER_BY_DESC);
25138                                            }
25139                                    }
25140                            }
25141                    }
25142                    else {
25143                            if (getDB().isSupportsInlineDistinct()) {
25144                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25145                            }
25146                            else {
25147                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25148                            }
25149                    }
25150    
25151                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25152                                    JournalArticle.class.getName(),
25153                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25154    
25155                    SQLQuery q = session.createSQLQuery(sql);
25156    
25157                    q.setFirstResult(0);
25158                    q.setMaxResults(2);
25159    
25160                    if (getDB().isSupportsInlineDistinct()) {
25161                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25162                    }
25163                    else {
25164                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25165                    }
25166    
25167                    QueryPos qPos = QueryPos.getInstance(q);
25168    
25169                    qPos.add(groupId);
25170    
25171                    if (bindArticleId) {
25172                            qPos.add(articleId);
25173                    }
25174    
25175                    qPos.add(status);
25176    
25177                    if (orderByComparator != null) {
25178                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25179    
25180                            for (Object value : values) {
25181                                    qPos.add(value);
25182                            }
25183                    }
25184    
25185                    List<JournalArticle> list = q.list();
25186    
25187                    if (list.size() == 2) {
25188                            return list.get(1);
25189                    }
25190                    else {
25191                            return null;
25192                    }
25193            }
25194    
25195            /**
25196             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25197             *
25198             * @param groupId the group ID
25199             * @param articleId the article ID
25200             * @param statuses the statuses
25201             * @return the matching journal articles that the user has permission to view
25202             * @throws SystemException if a system exception occurred
25203             */
25204            @Override
25205            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25206                    String articleId, int[] statuses) throws SystemException {
25207                    return filterFindByG_A_ST(groupId, articleId, statuses,
25208                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25209            }
25210    
25211            /**
25212             * 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;.
25213             *
25214             * <p>
25215             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25216             * </p>
25217             *
25218             * @param groupId the group ID
25219             * @param articleId the article ID
25220             * @param statuses the statuses
25221             * @param start the lower bound of the range of journal articles
25222             * @param end the upper bound of the range of journal articles (not inclusive)
25223             * @return the range of matching journal articles that the user has permission to view
25224             * @throws SystemException if a system exception occurred
25225             */
25226            @Override
25227            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25228                    String articleId, int[] statuses, int start, int end)
25229                    throws SystemException {
25230                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
25231            }
25232    
25233            /**
25234             * 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;.
25235             *
25236             * <p>
25237             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25238             * </p>
25239             *
25240             * @param groupId the group ID
25241             * @param articleId the article ID
25242             * @param statuses the statuses
25243             * @param start the lower bound of the range of journal articles
25244             * @param end the upper bound of the range of journal articles (not inclusive)
25245             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25246             * @return the ordered range of matching journal articles that the user has permission to view
25247             * @throws SystemException if a system exception occurred
25248             */
25249            @Override
25250            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25251                    String articleId, int[] statuses, int start, int end,
25252                    OrderByComparator orderByComparator) throws SystemException {
25253                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25254                            return findByG_A_ST(groupId, articleId, statuses, start, end,
25255                                    orderByComparator);
25256                    }
25257    
25258                    StringBundler query = new StringBundler();
25259    
25260                    if (getDB().isSupportsInlineDistinct()) {
25261                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25262                    }
25263                    else {
25264                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25265                    }
25266    
25267                    boolean conjunctionable = false;
25268    
25269                    if (conjunctionable) {
25270                            query.append(WHERE_AND);
25271                    }
25272    
25273                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
25274    
25275                    conjunctionable = true;
25276    
25277                    if (conjunctionable) {
25278                            query.append(WHERE_AND);
25279                    }
25280    
25281                    if (articleId == null) {
25282                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
25283                    }
25284                    else if (articleId.equals(StringPool.BLANK)) {
25285                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
25286                    }
25287                    else {
25288                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
25289                    }
25290    
25291                    conjunctionable = true;
25292    
25293                    if ((statuses == null) || (statuses.length > 0)) {
25294                            if (conjunctionable) {
25295                                    query.append(WHERE_AND);
25296                            }
25297    
25298                            query.append(StringPool.OPEN_PARENTHESIS);
25299    
25300                            for (int i = 0; i < statuses.length; i++) {
25301                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
25302    
25303                                    if ((i + 1) < statuses.length) {
25304                                            query.append(WHERE_OR);
25305                                    }
25306                            }
25307    
25308                            query.append(StringPool.CLOSE_PARENTHESIS);
25309    
25310                            conjunctionable = true;
25311                    }
25312    
25313                    if (!getDB().isSupportsInlineDistinct()) {
25314                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25315                    }
25316    
25317                    if (orderByComparator != null) {
25318                            if (getDB().isSupportsInlineDistinct()) {
25319                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25320                                            orderByComparator, true);
25321                            }
25322                            else {
25323                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25324                                            orderByComparator, true);
25325                            }
25326                    }
25327                    else {
25328                            if (getDB().isSupportsInlineDistinct()) {
25329                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25330                            }
25331                            else {
25332                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25333                            }
25334                    }
25335    
25336                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25337                                    JournalArticle.class.getName(),
25338                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25339    
25340                    Session session = null;
25341    
25342                    try {
25343                            session = openSession();
25344    
25345                            SQLQuery q = session.createSQLQuery(sql);
25346    
25347                            if (getDB().isSupportsInlineDistinct()) {
25348                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25349                            }
25350                            else {
25351                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25352                            }
25353    
25354                            QueryPos qPos = QueryPos.getInstance(q);
25355    
25356                            qPos.add(groupId);
25357    
25358                            if (articleId != null) {
25359                                    qPos.add(articleId);
25360                            }
25361    
25362                            if (statuses != null) {
25363                                    qPos.add(statuses);
25364                            }
25365    
25366                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25367                                    end);
25368                    }
25369                    catch (Exception e) {
25370                            throw processException(e);
25371                    }
25372                    finally {
25373                            closeSession(session);
25374                    }
25375            }
25376    
25377            /**
25378             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25379             *
25380             * <p>
25381             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25382             * </p>
25383             *
25384             * @param groupId the group ID
25385             * @param articleId the article ID
25386             * @param statuses the statuses
25387             * @return the matching journal articles
25388             * @throws SystemException if a system exception occurred
25389             */
25390            @Override
25391            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25392                    int[] statuses) throws SystemException {
25393                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
25394                            QueryUtil.ALL_POS, null);
25395            }
25396    
25397            /**
25398             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25399             *
25400             * <p>
25401             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25402             * </p>
25403             *
25404             * @param groupId the group ID
25405             * @param articleId the article ID
25406             * @param statuses the statuses
25407             * @param start the lower bound of the range of journal articles
25408             * @param end the upper bound of the range of journal articles (not inclusive)
25409             * @return the range of matching journal articles
25410             * @throws SystemException if a system exception occurred
25411             */
25412            @Override
25413            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25414                    int[] statuses, int start, int end) throws SystemException {
25415                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
25416            }
25417    
25418            /**
25419             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25420             *
25421             * <p>
25422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25423             * </p>
25424             *
25425             * @param groupId the group ID
25426             * @param articleId the article ID
25427             * @param statuses the statuses
25428             * @param start the lower bound of the range of journal articles
25429             * @param end the upper bound of the range of journal articles (not inclusive)
25430             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25431             * @return the ordered range of matching journal articles
25432             * @throws SystemException if a system exception occurred
25433             */
25434            @Override
25435            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25436                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
25437                    throws SystemException {
25438                    if ((statuses != null) && (statuses.length == 1)) {
25439                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
25440                                    orderByComparator);
25441                    }
25442    
25443                    boolean pagination = true;
25444                    Object[] finderArgs = null;
25445    
25446                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25447                                    (orderByComparator == null)) {
25448                            pagination = false;
25449                            finderArgs = new Object[] {
25450                                            groupId, articleId, StringUtil.merge(statuses)
25451                                    };
25452                    }
25453                    else {
25454                            finderArgs = new Object[] {
25455                                            groupId, articleId, StringUtil.merge(statuses),
25456                                            
25457                                            start, end, orderByComparator
25458                                    };
25459                    }
25460    
25461                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25462                                    finderArgs, this);
25463    
25464                    if ((list != null) && !list.isEmpty()) {
25465                            for (JournalArticle journalArticle : list) {
25466                                    if ((groupId != journalArticle.getGroupId()) ||
25467                                                    !Validator.equals(articleId,
25468                                                            journalArticle.getArticleId()) ||
25469                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
25470                                            list = null;
25471    
25472                                            break;
25473                                    }
25474                            }
25475                    }
25476    
25477                    if (list == null) {
25478                            StringBundler query = new StringBundler();
25479    
25480                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25481    
25482                            boolean conjunctionable = false;
25483    
25484                            if (conjunctionable) {
25485                                    query.append(WHERE_AND);
25486                            }
25487    
25488                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
25489    
25490                            conjunctionable = true;
25491    
25492                            if (conjunctionable) {
25493                                    query.append(WHERE_AND);
25494                            }
25495    
25496                            if (articleId == null) {
25497                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
25498                            }
25499                            else if (articleId.equals(StringPool.BLANK)) {
25500                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
25501                            }
25502                            else {
25503                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
25504                            }
25505    
25506                            conjunctionable = true;
25507    
25508                            if ((statuses == null) || (statuses.length > 0)) {
25509                                    if (conjunctionable) {
25510                                            query.append(WHERE_AND);
25511                                    }
25512    
25513                                    query.append(StringPool.OPEN_PARENTHESIS);
25514    
25515                                    for (int i = 0; i < statuses.length; i++) {
25516                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
25517    
25518                                            if ((i + 1) < statuses.length) {
25519                                                    query.append(WHERE_OR);
25520                                            }
25521                                    }
25522    
25523                                    query.append(StringPool.CLOSE_PARENTHESIS);
25524    
25525                                    conjunctionable = true;
25526                            }
25527    
25528                            if (orderByComparator != null) {
25529                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25530                                            orderByComparator);
25531                            }
25532                            else
25533                             if (pagination) {
25534                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25535                            }
25536    
25537                            String sql = query.toString();
25538    
25539                            Session session = null;
25540    
25541                            try {
25542                                    session = openSession();
25543    
25544                                    Query q = session.createQuery(sql);
25545    
25546                                    QueryPos qPos = QueryPos.getInstance(q);
25547    
25548                                    qPos.add(groupId);
25549    
25550                                    if (articleId != null) {
25551                                            qPos.add(articleId);
25552                                    }
25553    
25554                                    if (statuses != null) {
25555                                            qPos.add(statuses);
25556                                    }
25557    
25558                                    if (!pagination) {
25559                                            list = (List<JournalArticle>)QueryUtil.list(q,
25560                                                            getDialect(), start, end, false);
25561    
25562                                            Collections.sort(list);
25563    
25564                                            list = new UnmodifiableList<JournalArticle>(list);
25565                                    }
25566                                    else {
25567                                            list = (List<JournalArticle>)QueryUtil.list(q,
25568                                                            getDialect(), start, end);
25569                                    }
25570    
25571                                    cacheResult(list);
25572    
25573                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25574                                            finderArgs, list);
25575                            }
25576                            catch (Exception e) {
25577                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25578                                            finderArgs);
25579    
25580                                    throw processException(e);
25581                            }
25582                            finally {
25583                                    closeSession(session);
25584                            }
25585                    }
25586    
25587                    return list;
25588            }
25589    
25590            /**
25591             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
25592             *
25593             * @param groupId the group ID
25594             * @param articleId the article ID
25595             * @param status the status
25596             * @throws SystemException if a system exception occurred
25597             */
25598            @Override
25599            public void removeByG_A_ST(long groupId, String articleId, int status)
25600                    throws SystemException {
25601                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
25602                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
25603                            remove(journalArticle);
25604                    }
25605            }
25606    
25607            /**
25608             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25609             *
25610             * @param groupId the group ID
25611             * @param articleId the article ID
25612             * @param status the status
25613             * @return the number of matching journal articles
25614             * @throws SystemException if a system exception occurred
25615             */
25616            @Override
25617            public int countByG_A_ST(long groupId, String articleId, int status)
25618                    throws SystemException {
25619                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
25620    
25621                    Object[] finderArgs = new Object[] { groupId, articleId, status };
25622    
25623                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25624                                    this);
25625    
25626                    if (count == null) {
25627                            StringBundler query = new StringBundler(4);
25628    
25629                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25630    
25631                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25632    
25633                            boolean bindArticleId = false;
25634    
25635                            if (articleId == null) {
25636                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25637                            }
25638                            else if (articleId.equals(StringPool.BLANK)) {
25639                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25640                            }
25641                            else {
25642                                    bindArticleId = true;
25643    
25644                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25645                            }
25646    
25647                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25648    
25649                            String sql = query.toString();
25650    
25651                            Session session = null;
25652    
25653                            try {
25654                                    session = openSession();
25655    
25656                                    Query q = session.createQuery(sql);
25657    
25658                                    QueryPos qPos = QueryPos.getInstance(q);
25659    
25660                                    qPos.add(groupId);
25661    
25662                                    if (bindArticleId) {
25663                                            qPos.add(articleId);
25664                                    }
25665    
25666                                    qPos.add(status);
25667    
25668                                    count = (Long)q.uniqueResult();
25669    
25670                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25671                            }
25672                            catch (Exception e) {
25673                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25674    
25675                                    throw processException(e);
25676                            }
25677                            finally {
25678                                    closeSession(session);
25679                            }
25680                    }
25681    
25682                    return count.intValue();
25683            }
25684    
25685            /**
25686             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25687             *
25688             * @param groupId the group ID
25689             * @param articleId the article ID
25690             * @param statuses the statuses
25691             * @return the number of matching journal articles
25692             * @throws SystemException if a system exception occurred
25693             */
25694            @Override
25695            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
25696                    throws SystemException {
25697                    Object[] finderArgs = new Object[] {
25698                                    groupId, articleId, StringUtil.merge(statuses)
25699                            };
25700    
25701                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25702                                    finderArgs, this);
25703    
25704                    if (count == null) {
25705                            StringBundler query = new StringBundler();
25706    
25707                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25708    
25709                            boolean conjunctionable = false;
25710    
25711                            if (conjunctionable) {
25712                                    query.append(WHERE_AND);
25713                            }
25714    
25715                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
25716    
25717                            conjunctionable = true;
25718    
25719                            if (conjunctionable) {
25720                                    query.append(WHERE_AND);
25721                            }
25722    
25723                            if (articleId == null) {
25724                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
25725                            }
25726                            else if (articleId.equals(StringPool.BLANK)) {
25727                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
25728                            }
25729                            else {
25730                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
25731                            }
25732    
25733                            conjunctionable = true;
25734    
25735                            if ((statuses == null) || (statuses.length > 0)) {
25736                                    if (conjunctionable) {
25737                                            query.append(WHERE_AND);
25738                                    }
25739    
25740                                    query.append(StringPool.OPEN_PARENTHESIS);
25741    
25742                                    for (int i = 0; i < statuses.length; i++) {
25743                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
25744    
25745                                            if ((i + 1) < statuses.length) {
25746                                                    query.append(WHERE_OR);
25747                                            }
25748                                    }
25749    
25750                                    query.append(StringPool.CLOSE_PARENTHESIS);
25751    
25752                                    conjunctionable = true;
25753                            }
25754    
25755                            String sql = query.toString();
25756    
25757                            Session session = null;
25758    
25759                            try {
25760                                    session = openSession();
25761    
25762                                    Query q = session.createQuery(sql);
25763    
25764                                    QueryPos qPos = QueryPos.getInstance(q);
25765    
25766                                    qPos.add(groupId);
25767    
25768                                    if (articleId != null) {
25769                                            qPos.add(articleId);
25770                                    }
25771    
25772                                    if (statuses != null) {
25773                                            qPos.add(statuses);
25774                                    }
25775    
25776                                    count = (Long)q.uniqueResult();
25777    
25778                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25779                                            finderArgs, count);
25780                            }
25781                            catch (Exception e) {
25782                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25783                                            finderArgs);
25784    
25785                                    throw processException(e);
25786                            }
25787                            finally {
25788                                    closeSession(session);
25789                            }
25790                    }
25791    
25792                    return count.intValue();
25793            }
25794    
25795            /**
25796             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25797             *
25798             * @param groupId the group ID
25799             * @param articleId the article ID
25800             * @param status the status
25801             * @return the number of matching journal articles that the user has permission to view
25802             * @throws SystemException if a system exception occurred
25803             */
25804            @Override
25805            public int filterCountByG_A_ST(long groupId, String articleId, int status)
25806                    throws SystemException {
25807                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25808                            return countByG_A_ST(groupId, articleId, status);
25809                    }
25810    
25811                    StringBundler query = new StringBundler(4);
25812    
25813                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25814    
25815                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25816    
25817                    boolean bindArticleId = false;
25818    
25819                    if (articleId == null) {
25820                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25821                    }
25822                    else if (articleId.equals(StringPool.BLANK)) {
25823                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25824                    }
25825                    else {
25826                            bindArticleId = true;
25827    
25828                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25829                    }
25830    
25831                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25832    
25833                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25834                                    JournalArticle.class.getName(),
25835                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25836    
25837                    Session session = null;
25838    
25839                    try {
25840                            session = openSession();
25841    
25842                            SQLQuery q = session.createSQLQuery(sql);
25843    
25844                            q.addScalar(COUNT_COLUMN_NAME,
25845                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
25846    
25847                            QueryPos qPos = QueryPos.getInstance(q);
25848    
25849                            qPos.add(groupId);
25850    
25851                            if (bindArticleId) {
25852                                    qPos.add(articleId);
25853                            }
25854    
25855                            qPos.add(status);
25856    
25857                            Long count = (Long)q.uniqueResult();
25858    
25859                            return count.intValue();
25860                    }
25861                    catch (Exception e) {
25862                            throw processException(e);
25863                    }
25864                    finally {
25865                            closeSession(session);
25866                    }
25867            }
25868    
25869            /**
25870             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25871             *
25872             * @param groupId the group ID
25873             * @param articleId the article ID
25874             * @param statuses the statuses
25875             * @return the number of matching journal articles that the user has permission to view
25876             * @throws SystemException if a system exception occurred
25877             */
25878            @Override
25879            public int filterCountByG_A_ST(long groupId, String articleId,
25880                    int[] statuses) throws SystemException {
25881                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25882                            return countByG_A_ST(groupId, articleId, statuses);
25883                    }
25884    
25885                    StringBundler query = new StringBundler();
25886    
25887                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25888    
25889                    boolean conjunctionable = false;
25890    
25891                    if (conjunctionable) {
25892                            query.append(WHERE_AND);
25893                    }
25894    
25895                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
25896    
25897                    conjunctionable = true;
25898    
25899                    if (conjunctionable) {
25900                            query.append(WHERE_AND);
25901                    }
25902    
25903                    if (articleId == null) {
25904                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
25905                    }
25906                    else if (articleId.equals(StringPool.BLANK)) {
25907                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
25908                    }
25909                    else {
25910                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
25911                    }
25912    
25913                    conjunctionable = true;
25914    
25915                    if ((statuses == null) || (statuses.length > 0)) {
25916                            if (conjunctionable) {
25917                                    query.append(WHERE_AND);
25918                            }
25919    
25920                            query.append(StringPool.OPEN_PARENTHESIS);
25921    
25922                            for (int i = 0; i < statuses.length; i++) {
25923                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
25924    
25925                                    if ((i + 1) < statuses.length) {
25926                                            query.append(WHERE_OR);
25927                                    }
25928                            }
25929    
25930                            query.append(StringPool.CLOSE_PARENTHESIS);
25931    
25932                            conjunctionable = true;
25933                    }
25934    
25935                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25936                                    JournalArticle.class.getName(),
25937                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25938    
25939                    Session session = null;
25940    
25941                    try {
25942                            session = openSession();
25943    
25944                            SQLQuery q = session.createSQLQuery(sql);
25945    
25946                            q.addScalar(COUNT_COLUMN_NAME,
25947                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
25948    
25949                            QueryPos qPos = QueryPos.getInstance(q);
25950    
25951                            qPos.add(groupId);
25952    
25953                            if (articleId != null) {
25954                                    qPos.add(articleId);
25955                            }
25956    
25957                            if (statuses != null) {
25958                                    qPos.add(statuses);
25959                            }
25960    
25961                            Long count = (Long)q.uniqueResult();
25962    
25963                            return count.intValue();
25964                    }
25965                    catch (Exception e) {
25966                            throw processException(e);
25967                    }
25968                    finally {
25969                            closeSession(session);
25970                    }
25971            }
25972    
25973            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
25974            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
25975                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
25976            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
25977            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
25978            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
25979            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
25980                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
25981            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
25982                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
25983            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
25984                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
25985            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
25986            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
25987                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
25988            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST =
25989                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25990                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25991                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
25992                            "findByG_A_NotST",
25993                            new String[] {
25994                                    Long.class.getName(), String.class.getName(),
25995                                    Integer.class.getName(),
25996                                    
25997                            Integer.class.getName(), Integer.class.getName(),
25998                                    OrderByComparator.class.getName()
25999                            });
26000            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST =
26001                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26002                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26003                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_NotST",
26004                            new String[] {
26005                                    Long.class.getName(), String.class.getName(),
26006                                    Integer.class.getName()
26007                            });
26008    
26009            /**
26010             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26011             *
26012             * @param groupId the group ID
26013             * @param articleId the article ID
26014             * @param status the status
26015             * @return the matching journal articles
26016             * @throws SystemException if a system exception occurred
26017             */
26018            @Override
26019            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26020                    int status) throws SystemException {
26021                    return findByG_A_NotST(groupId, articleId, status, QueryUtil.ALL_POS,
26022                            QueryUtil.ALL_POS, null);
26023            }
26024    
26025            /**
26026             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26027             *
26028             * <p>
26029             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26030             * </p>
26031             *
26032             * @param groupId the group ID
26033             * @param articleId the article ID
26034             * @param status the status
26035             * @param start the lower bound of the range of journal articles
26036             * @param end the upper bound of the range of journal articles (not inclusive)
26037             * @return the range of matching journal articles
26038             * @throws SystemException if a system exception occurred
26039             */
26040            @Override
26041            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26042                    int status, int start, int end) throws SystemException {
26043                    return findByG_A_NotST(groupId, articleId, status, start, end, null);
26044            }
26045    
26046            /**
26047             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26048             *
26049             * <p>
26050             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26051             * </p>
26052             *
26053             * @param groupId the group ID
26054             * @param articleId the article ID
26055             * @param status the status
26056             * @param start the lower bound of the range of journal articles
26057             * @param end the upper bound of the range of journal articles (not inclusive)
26058             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26059             * @return the ordered range of matching journal articles
26060             * @throws SystemException if a system exception occurred
26061             */
26062            @Override
26063            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26064                    int status, int start, int end, OrderByComparator orderByComparator)
26065                    throws SystemException {
26066                    boolean pagination = true;
26067                    FinderPath finderPath = null;
26068                    Object[] finderArgs = null;
26069    
26070                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST;
26071                    finderArgs = new Object[] {
26072                                    groupId, articleId, status,
26073                                    
26074                                    start, end, orderByComparator
26075                            };
26076    
26077                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26078                                    finderArgs, this);
26079    
26080                    if ((list != null) && !list.isEmpty()) {
26081                            for (JournalArticle journalArticle : list) {
26082                                    if ((groupId != journalArticle.getGroupId()) ||
26083                                                    !Validator.equals(articleId,
26084                                                            journalArticle.getArticleId()) ||
26085                                                    (status == journalArticle.getStatus())) {
26086                                            list = null;
26087    
26088                                            break;
26089                                    }
26090                            }
26091                    }
26092    
26093                    if (list == null) {
26094                            StringBundler query = null;
26095    
26096                            if (orderByComparator != null) {
26097                                    query = new StringBundler(5 +
26098                                                    (orderByComparator.getOrderByFields().length * 3));
26099                            }
26100                            else {
26101                                    query = new StringBundler(5);
26102                            }
26103    
26104                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26105    
26106                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26107    
26108                            boolean bindArticleId = false;
26109    
26110                            if (articleId == null) {
26111                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26112                            }
26113                            else if (articleId.equals(StringPool.BLANK)) {
26114                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26115                            }
26116                            else {
26117                                    bindArticleId = true;
26118    
26119                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26120                            }
26121    
26122                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26123    
26124                            if (orderByComparator != null) {
26125                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26126                                            orderByComparator);
26127                            }
26128                            else
26129                             if (pagination) {
26130                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26131                            }
26132    
26133                            String sql = query.toString();
26134    
26135                            Session session = null;
26136    
26137                            try {
26138                                    session = openSession();
26139    
26140                                    Query q = session.createQuery(sql);
26141    
26142                                    QueryPos qPos = QueryPos.getInstance(q);
26143    
26144                                    qPos.add(groupId);
26145    
26146                                    if (bindArticleId) {
26147                                            qPos.add(articleId);
26148                                    }
26149    
26150                                    qPos.add(status);
26151    
26152                                    if (!pagination) {
26153                                            list = (List<JournalArticle>)QueryUtil.list(q,
26154                                                            getDialect(), start, end, false);
26155    
26156                                            Collections.sort(list);
26157    
26158                                            list = new UnmodifiableList<JournalArticle>(list);
26159                                    }
26160                                    else {
26161                                            list = (List<JournalArticle>)QueryUtil.list(q,
26162                                                            getDialect(), start, end);
26163                                    }
26164    
26165                                    cacheResult(list);
26166    
26167                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
26168                            }
26169                            catch (Exception e) {
26170                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26171    
26172                                    throw processException(e);
26173                            }
26174                            finally {
26175                                    closeSession(session);
26176                            }
26177                    }
26178    
26179                    return list;
26180            }
26181    
26182            /**
26183             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26184             *
26185             * @param groupId the group ID
26186             * @param articleId the article ID
26187             * @param status the status
26188             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26189             * @return the first matching journal article
26190             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26191             * @throws SystemException if a system exception occurred
26192             */
26193            @Override
26194            public JournalArticle findByG_A_NotST_First(long groupId, String articleId,
26195                    int status, OrderByComparator orderByComparator)
26196                    throws NoSuchArticleException, SystemException {
26197                    JournalArticle journalArticle = fetchByG_A_NotST_First(groupId,
26198                                    articleId, status, orderByComparator);
26199    
26200                    if (journalArticle != null) {
26201                            return journalArticle;
26202                    }
26203    
26204                    StringBundler msg = new StringBundler(8);
26205    
26206                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26207    
26208                    msg.append("groupId=");
26209                    msg.append(groupId);
26210    
26211                    msg.append(", articleId=");
26212                    msg.append(articleId);
26213    
26214                    msg.append(", status=");
26215                    msg.append(status);
26216    
26217                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26218    
26219                    throw new NoSuchArticleException(msg.toString());
26220            }
26221    
26222            /**
26223             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26224             *
26225             * @param groupId the group ID
26226             * @param articleId the article ID
26227             * @param status the status
26228             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26229             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
26230             * @throws SystemException if a system exception occurred
26231             */
26232            @Override
26233            public JournalArticle fetchByG_A_NotST_First(long groupId,
26234                    String articleId, int status, OrderByComparator orderByComparator)
26235                    throws SystemException {
26236                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
26237                                    0, 1, orderByComparator);
26238    
26239                    if (!list.isEmpty()) {
26240                            return list.get(0);
26241                    }
26242    
26243                    return null;
26244            }
26245    
26246            /**
26247             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26248             *
26249             * @param groupId the group ID
26250             * @param articleId the article ID
26251             * @param status the status
26252             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26253             * @return the last matching journal article
26254             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26255             * @throws SystemException if a system exception occurred
26256             */
26257            @Override
26258            public JournalArticle findByG_A_NotST_Last(long groupId, String articleId,
26259                    int status, OrderByComparator orderByComparator)
26260                    throws NoSuchArticleException, SystemException {
26261                    JournalArticle journalArticle = fetchByG_A_NotST_Last(groupId,
26262                                    articleId, status, orderByComparator);
26263    
26264                    if (journalArticle != null) {
26265                            return journalArticle;
26266                    }
26267    
26268                    StringBundler msg = new StringBundler(8);
26269    
26270                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26271    
26272                    msg.append("groupId=");
26273                    msg.append(groupId);
26274    
26275                    msg.append(", articleId=");
26276                    msg.append(articleId);
26277    
26278                    msg.append(", status=");
26279                    msg.append(status);
26280    
26281                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26282    
26283                    throw new NoSuchArticleException(msg.toString());
26284            }
26285    
26286            /**
26287             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26288             *
26289             * @param groupId the group ID
26290             * @param articleId the article ID
26291             * @param status the status
26292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26293             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
26294             * @throws SystemException if a system exception occurred
26295             */
26296            @Override
26297            public JournalArticle fetchByG_A_NotST_Last(long groupId, String articleId,
26298                    int status, OrderByComparator orderByComparator)
26299                    throws SystemException {
26300                    int count = countByG_A_NotST(groupId, articleId, status);
26301    
26302                    if (count == 0) {
26303                            return null;
26304                    }
26305    
26306                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
26307                                    count - 1, count, orderByComparator);
26308    
26309                    if (!list.isEmpty()) {
26310                            return list.get(0);
26311                    }
26312    
26313                    return null;
26314            }
26315    
26316            /**
26317             * 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;.
26318             *
26319             * @param id the primary key of the current journal article
26320             * @param groupId the group ID
26321             * @param articleId the article ID
26322             * @param status the status
26323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26324             * @return the previous, current, and next journal article
26325             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26326             * @throws SystemException if a system exception occurred
26327             */
26328            @Override
26329            public JournalArticle[] findByG_A_NotST_PrevAndNext(long id, long groupId,
26330                    String articleId, int status, OrderByComparator orderByComparator)
26331                    throws NoSuchArticleException, SystemException {
26332                    JournalArticle journalArticle = findByPrimaryKey(id);
26333    
26334                    Session session = null;
26335    
26336                    try {
26337                            session = openSession();
26338    
26339                            JournalArticle[] array = new JournalArticleImpl[3];
26340    
26341                            array[0] = getByG_A_NotST_PrevAndNext(session, journalArticle,
26342                                            groupId, articleId, status, orderByComparator, true);
26343    
26344                            array[1] = journalArticle;
26345    
26346                            array[2] = getByG_A_NotST_PrevAndNext(session, journalArticle,
26347                                            groupId, articleId, status, orderByComparator, false);
26348    
26349                            return array;
26350                    }
26351                    catch (Exception e) {
26352                            throw processException(e);
26353                    }
26354                    finally {
26355                            closeSession(session);
26356                    }
26357            }
26358    
26359            protected JournalArticle getByG_A_NotST_PrevAndNext(Session session,
26360                    JournalArticle journalArticle, long groupId, String articleId,
26361                    int status, OrderByComparator orderByComparator, boolean previous) {
26362                    StringBundler query = null;
26363    
26364                    if (orderByComparator != null) {
26365                            query = new StringBundler(6 +
26366                                            (orderByComparator.getOrderByFields().length * 6));
26367                    }
26368                    else {
26369                            query = new StringBundler(3);
26370                    }
26371    
26372                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26373    
26374                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26375    
26376                    boolean bindArticleId = false;
26377    
26378                    if (articleId == null) {
26379                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26380                    }
26381                    else if (articleId.equals(StringPool.BLANK)) {
26382                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26383                    }
26384                    else {
26385                            bindArticleId = true;
26386    
26387                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26388                    }
26389    
26390                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26391    
26392                    if (orderByComparator != null) {
26393                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26394    
26395                            if (orderByConditionFields.length > 0) {
26396                                    query.append(WHERE_AND);
26397                            }
26398    
26399                            for (int i = 0; i < orderByConditionFields.length; i++) {
26400                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26401                                    query.append(orderByConditionFields[i]);
26402    
26403                                    if ((i + 1) < orderByConditionFields.length) {
26404                                            if (orderByComparator.isAscending() ^ previous) {
26405                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26406                                            }
26407                                            else {
26408                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26409                                            }
26410                                    }
26411                                    else {
26412                                            if (orderByComparator.isAscending() ^ previous) {
26413                                                    query.append(WHERE_GREATER_THAN);
26414                                            }
26415                                            else {
26416                                                    query.append(WHERE_LESSER_THAN);
26417                                            }
26418                                    }
26419                            }
26420    
26421                            query.append(ORDER_BY_CLAUSE);
26422    
26423                            String[] orderByFields = orderByComparator.getOrderByFields();
26424    
26425                            for (int i = 0; i < orderByFields.length; i++) {
26426                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26427                                    query.append(orderByFields[i]);
26428    
26429                                    if ((i + 1) < orderByFields.length) {
26430                                            if (orderByComparator.isAscending() ^ previous) {
26431                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26432                                            }
26433                                            else {
26434                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26435                                            }
26436                                    }
26437                                    else {
26438                                            if (orderByComparator.isAscending() ^ previous) {
26439                                                    query.append(ORDER_BY_ASC);
26440                                            }
26441                                            else {
26442                                                    query.append(ORDER_BY_DESC);
26443                                            }
26444                                    }
26445                            }
26446                    }
26447                    else {
26448                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26449                    }
26450    
26451                    String sql = query.toString();
26452    
26453                    Query q = session.createQuery(sql);
26454    
26455                    q.setFirstResult(0);
26456                    q.setMaxResults(2);
26457    
26458                    QueryPos qPos = QueryPos.getInstance(q);
26459    
26460                    qPos.add(groupId);
26461    
26462                    if (bindArticleId) {
26463                            qPos.add(articleId);
26464                    }
26465    
26466                    qPos.add(status);
26467    
26468                    if (orderByComparator != null) {
26469                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26470    
26471                            for (Object value : values) {
26472                                    qPos.add(value);
26473                            }
26474                    }
26475    
26476                    List<JournalArticle> list = q.list();
26477    
26478                    if (list.size() == 2) {
26479                            return list.get(1);
26480                    }
26481                    else {
26482                            return null;
26483                    }
26484            }
26485    
26486            /**
26487             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26488             *
26489             * @param groupId the group ID
26490             * @param articleId the article ID
26491             * @param status the status
26492             * @return the matching journal articles that the user has permission to view
26493             * @throws SystemException if a system exception occurred
26494             */
26495            @Override
26496            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26497                    String articleId, int status) throws SystemException {
26498                    return filterFindByG_A_NotST(groupId, articleId, status,
26499                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
26500            }
26501    
26502            /**
26503             * 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;.
26504             *
26505             * <p>
26506             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26507             * </p>
26508             *
26509             * @param groupId the group ID
26510             * @param articleId the article ID
26511             * @param status the status
26512             * @param start the lower bound of the range of journal articles
26513             * @param end the upper bound of the range of journal articles (not inclusive)
26514             * @return the range of matching journal articles that the user has permission to view
26515             * @throws SystemException if a system exception occurred
26516             */
26517            @Override
26518            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26519                    String articleId, int status, int start, int end)
26520                    throws SystemException {
26521                    return filterFindByG_A_NotST(groupId, articleId, status, start, end,
26522                            null);
26523            }
26524    
26525            /**
26526             * 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;.
26527             *
26528             * <p>
26529             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26530             * </p>
26531             *
26532             * @param groupId the group ID
26533             * @param articleId the article ID
26534             * @param status the status
26535             * @param start the lower bound of the range of journal articles
26536             * @param end the upper bound of the range of journal articles (not inclusive)
26537             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26538             * @return the ordered range of matching journal articles that the user has permission to view
26539             * @throws SystemException if a system exception occurred
26540             */
26541            @Override
26542            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26543                    String articleId, int status, int start, int end,
26544                    OrderByComparator orderByComparator) throws SystemException {
26545                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26546                            return findByG_A_NotST(groupId, articleId, status, start, end,
26547                                    orderByComparator);
26548                    }
26549    
26550                    StringBundler query = null;
26551    
26552                    if (orderByComparator != null) {
26553                            query = new StringBundler(5 +
26554                                            (orderByComparator.getOrderByFields().length * 3));
26555                    }
26556                    else {
26557                            query = new StringBundler(5);
26558                    }
26559    
26560                    if (getDB().isSupportsInlineDistinct()) {
26561                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26562                    }
26563                    else {
26564                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26565                    }
26566    
26567                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26568    
26569                    boolean bindArticleId = false;
26570    
26571                    if (articleId == null) {
26572                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26573                    }
26574                    else if (articleId.equals(StringPool.BLANK)) {
26575                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26576                    }
26577                    else {
26578                            bindArticleId = true;
26579    
26580                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26581                    }
26582    
26583                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26584    
26585                    if (!getDB().isSupportsInlineDistinct()) {
26586                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26587                    }
26588    
26589                    if (orderByComparator != null) {
26590                            if (getDB().isSupportsInlineDistinct()) {
26591                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26592                                            orderByComparator, true);
26593                            }
26594                            else {
26595                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
26596                                            orderByComparator, true);
26597                            }
26598                    }
26599                    else {
26600                            if (getDB().isSupportsInlineDistinct()) {
26601                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26602                            }
26603                            else {
26604                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26605                            }
26606                    }
26607    
26608                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26609                                    JournalArticle.class.getName(),
26610                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26611    
26612                    Session session = null;
26613    
26614                    try {
26615                            session = openSession();
26616    
26617                            SQLQuery q = session.createSQLQuery(sql);
26618    
26619                            if (getDB().isSupportsInlineDistinct()) {
26620                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26621                            }
26622                            else {
26623                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26624                            }
26625    
26626                            QueryPos qPos = QueryPos.getInstance(q);
26627    
26628                            qPos.add(groupId);
26629    
26630                            if (bindArticleId) {
26631                                    qPos.add(articleId);
26632                            }
26633    
26634                            qPos.add(status);
26635    
26636                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
26637                                    end);
26638                    }
26639                    catch (Exception e) {
26640                            throw processException(e);
26641                    }
26642                    finally {
26643                            closeSession(session);
26644                    }
26645            }
26646    
26647            /**
26648             * 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;.
26649             *
26650             * @param id the primary key of the current journal article
26651             * @param groupId the group ID
26652             * @param articleId the article ID
26653             * @param status the status
26654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26655             * @return the previous, current, and next journal article
26656             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26657             * @throws SystemException if a system exception occurred
26658             */
26659            @Override
26660            public JournalArticle[] filterFindByG_A_NotST_PrevAndNext(long id,
26661                    long groupId, String articleId, int status,
26662                    OrderByComparator orderByComparator)
26663                    throws NoSuchArticleException, SystemException {
26664                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26665                            return findByG_A_NotST_PrevAndNext(id, groupId, articleId, status,
26666                                    orderByComparator);
26667                    }
26668    
26669                    JournalArticle journalArticle = findByPrimaryKey(id);
26670    
26671                    Session session = null;
26672    
26673                    try {
26674                            session = openSession();
26675    
26676                            JournalArticle[] array = new JournalArticleImpl[3];
26677    
26678                            array[0] = filterGetByG_A_NotST_PrevAndNext(session,
26679                                            journalArticle, groupId, articleId, status,
26680                                            orderByComparator, true);
26681    
26682                            array[1] = journalArticle;
26683    
26684                            array[2] = filterGetByG_A_NotST_PrevAndNext(session,
26685                                            journalArticle, groupId, articleId, status,
26686                                            orderByComparator, false);
26687    
26688                            return array;
26689                    }
26690                    catch (Exception e) {
26691                            throw processException(e);
26692                    }
26693                    finally {
26694                            closeSession(session);
26695                    }
26696            }
26697    
26698            protected JournalArticle filterGetByG_A_NotST_PrevAndNext(Session session,
26699                    JournalArticle journalArticle, long groupId, String articleId,
26700                    int status, OrderByComparator orderByComparator, boolean previous) {
26701                    StringBundler query = null;
26702    
26703                    if (orderByComparator != null) {
26704                            query = new StringBundler(6 +
26705                                            (orderByComparator.getOrderByFields().length * 6));
26706                    }
26707                    else {
26708                            query = new StringBundler(3);
26709                    }
26710    
26711                    if (getDB().isSupportsInlineDistinct()) {
26712                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26713                    }
26714                    else {
26715                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26716                    }
26717    
26718                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26719    
26720                    boolean bindArticleId = false;
26721    
26722                    if (articleId == null) {
26723                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26724                    }
26725                    else if (articleId.equals(StringPool.BLANK)) {
26726                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26727                    }
26728                    else {
26729                            bindArticleId = true;
26730    
26731                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26732                    }
26733    
26734                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26735    
26736                    if (!getDB().isSupportsInlineDistinct()) {
26737                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26738                    }
26739    
26740                    if (orderByComparator != null) {
26741                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26742    
26743                            if (orderByConditionFields.length > 0) {
26744                                    query.append(WHERE_AND);
26745                            }
26746    
26747                            for (int i = 0; i < orderByConditionFields.length; i++) {
26748                                    if (getDB().isSupportsInlineDistinct()) {
26749                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26750                                    }
26751                                    else {
26752                                            query.append(_ORDER_BY_ENTITY_TABLE);
26753                                    }
26754    
26755                                    query.append(orderByConditionFields[i]);
26756    
26757                                    if ((i + 1) < orderByConditionFields.length) {
26758                                            if (orderByComparator.isAscending() ^ previous) {
26759                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26760                                            }
26761                                            else {
26762                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26763                                            }
26764                                    }
26765                                    else {
26766                                            if (orderByComparator.isAscending() ^ previous) {
26767                                                    query.append(WHERE_GREATER_THAN);
26768                                            }
26769                                            else {
26770                                                    query.append(WHERE_LESSER_THAN);
26771                                            }
26772                                    }
26773                            }
26774    
26775                            query.append(ORDER_BY_CLAUSE);
26776    
26777                            String[] orderByFields = orderByComparator.getOrderByFields();
26778    
26779                            for (int i = 0; i < orderByFields.length; i++) {
26780                                    if (getDB().isSupportsInlineDistinct()) {
26781                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26782                                    }
26783                                    else {
26784                                            query.append(_ORDER_BY_ENTITY_TABLE);
26785                                    }
26786    
26787                                    query.append(orderByFields[i]);
26788    
26789                                    if ((i + 1) < orderByFields.length) {
26790                                            if (orderByComparator.isAscending() ^ previous) {
26791                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26792                                            }
26793                                            else {
26794                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26795                                            }
26796                                    }
26797                                    else {
26798                                            if (orderByComparator.isAscending() ^ previous) {
26799                                                    query.append(ORDER_BY_ASC);
26800                                            }
26801                                            else {
26802                                                    query.append(ORDER_BY_DESC);
26803                                            }
26804                                    }
26805                            }
26806                    }
26807                    else {
26808                            if (getDB().isSupportsInlineDistinct()) {
26809                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26810                            }
26811                            else {
26812                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26813                            }
26814                    }
26815    
26816                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26817                                    JournalArticle.class.getName(),
26818                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26819    
26820                    SQLQuery q = session.createSQLQuery(sql);
26821    
26822                    q.setFirstResult(0);
26823                    q.setMaxResults(2);
26824    
26825                    if (getDB().isSupportsInlineDistinct()) {
26826                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26827                    }
26828                    else {
26829                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26830                    }
26831    
26832                    QueryPos qPos = QueryPos.getInstance(q);
26833    
26834                    qPos.add(groupId);
26835    
26836                    if (bindArticleId) {
26837                            qPos.add(articleId);
26838                    }
26839    
26840                    qPos.add(status);
26841    
26842                    if (orderByComparator != null) {
26843                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26844    
26845                            for (Object value : values) {
26846                                    qPos.add(value);
26847                            }
26848                    }
26849    
26850                    List<JournalArticle> list = q.list();
26851    
26852                    if (list.size() == 2) {
26853                            return list.get(1);
26854                    }
26855                    else {
26856                            return null;
26857                    }
26858            }
26859    
26860            /**
26861             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63; from the database.
26862             *
26863             * @param groupId the group ID
26864             * @param articleId the article ID
26865             * @param status the status
26866             * @throws SystemException if a system exception occurred
26867             */
26868            @Override
26869            public void removeByG_A_NotST(long groupId, String articleId, int status)
26870                    throws SystemException {
26871                    for (JournalArticle journalArticle : findByG_A_NotST(groupId,
26872                                    articleId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26873                            remove(journalArticle);
26874                    }
26875            }
26876    
26877            /**
26878             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26879             *
26880             * @param groupId the group ID
26881             * @param articleId the article ID
26882             * @param status the status
26883             * @return the number of matching journal articles
26884             * @throws SystemException if a system exception occurred
26885             */
26886            @Override
26887            public int countByG_A_NotST(long groupId, String articleId, int status)
26888                    throws SystemException {
26889                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST;
26890    
26891                    Object[] finderArgs = new Object[] { groupId, articleId, status };
26892    
26893                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26894                                    this);
26895    
26896                    if (count == null) {
26897                            StringBundler query = new StringBundler(4);
26898    
26899                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26900    
26901                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26902    
26903                            boolean bindArticleId = false;
26904    
26905                            if (articleId == null) {
26906                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26907                            }
26908                            else if (articleId.equals(StringPool.BLANK)) {
26909                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26910                            }
26911                            else {
26912                                    bindArticleId = true;
26913    
26914                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26915                            }
26916    
26917                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26918    
26919                            String sql = query.toString();
26920    
26921                            Session session = null;
26922    
26923                            try {
26924                                    session = openSession();
26925    
26926                                    Query q = session.createQuery(sql);
26927    
26928                                    QueryPos qPos = QueryPos.getInstance(q);
26929    
26930                                    qPos.add(groupId);
26931    
26932                                    if (bindArticleId) {
26933                                            qPos.add(articleId);
26934                                    }
26935    
26936                                    qPos.add(status);
26937    
26938                                    count = (Long)q.uniqueResult();
26939    
26940                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26941                            }
26942                            catch (Exception e) {
26943                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26944    
26945                                    throw processException(e);
26946                            }
26947                            finally {
26948                                    closeSession(session);
26949                            }
26950                    }
26951    
26952                    return count.intValue();
26953            }
26954    
26955            /**
26956             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26957             *
26958             * @param groupId the group ID
26959             * @param articleId the article ID
26960             * @param status the status
26961             * @return the number of matching journal articles that the user has permission to view
26962             * @throws SystemException if a system exception occurred
26963             */
26964            @Override
26965            public int filterCountByG_A_NotST(long groupId, String articleId, int status)
26966                    throws SystemException {
26967                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26968                            return countByG_A_NotST(groupId, articleId, status);
26969                    }
26970    
26971                    StringBundler query = new StringBundler(4);
26972    
26973                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26974    
26975                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26976    
26977                    boolean bindArticleId = false;
26978    
26979                    if (articleId == null) {
26980                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26981                    }
26982                    else if (articleId.equals(StringPool.BLANK)) {
26983                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26984                    }
26985                    else {
26986                            bindArticleId = true;
26987    
26988                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26989                    }
26990    
26991                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26992    
26993                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26994                                    JournalArticle.class.getName(),
26995                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26996    
26997                    Session session = null;
26998    
26999                    try {
27000                            session = openSession();
27001    
27002                            SQLQuery q = session.createSQLQuery(sql);
27003    
27004                            q.addScalar(COUNT_COLUMN_NAME,
27005                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
27006    
27007                            QueryPos qPos = QueryPos.getInstance(q);
27008    
27009                            qPos.add(groupId);
27010    
27011                            if (bindArticleId) {
27012                                    qPos.add(articleId);
27013                            }
27014    
27015                            qPos.add(status);
27016    
27017                            Long count = (Long)q.uniqueResult();
27018    
27019                            return count.intValue();
27020                    }
27021                    catch (Exception e) {
27022                            throw processException(e);
27023                    }
27024                    finally {
27025                            closeSession(session);
27026                    }
27027            }
27028    
27029            private static final String _FINDER_COLUMN_G_A_NOTST_GROUPID_2 = "journalArticle.groupId = ? AND ";
27030            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
27031            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
27032            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
27033            private static final String _FINDER_COLUMN_G_A_NOTST_STATUS_2 = "journalArticle.status != ?";
27034            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27035                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27036                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
27037                            "findByG_UT_ST",
27038                            new String[] {
27039                                    Long.class.getName(), String.class.getName(),
27040                                    Integer.class.getName(),
27041                                    
27042                            Integer.class.getName(), Integer.class.getName(),
27043                                    OrderByComparator.class.getName()
27044                            });
27045            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
27046                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27047                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27048                            JournalArticleImpl.class,
27049                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
27050                            new String[] {
27051                                    Long.class.getName(), String.class.getName(),
27052                                    Integer.class.getName()
27053                            },
27054                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
27055                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
27056                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
27057                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
27058                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
27059            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27060                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
27061                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
27062                            new String[] {
27063                                    Long.class.getName(), String.class.getName(),
27064                                    Integer.class.getName()
27065                            });
27066    
27067            /**
27068             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27069             *
27070             * @param groupId the group ID
27071             * @param urlTitle the url title
27072             * @param status the status
27073             * @return the matching journal articles
27074             * @throws SystemException if a system exception occurred
27075             */
27076            @Override
27077            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27078                    int status) throws SystemException {
27079                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
27080                            QueryUtil.ALL_POS, null);
27081            }
27082    
27083            /**
27084             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27085             *
27086             * <p>
27087             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27088             * </p>
27089             *
27090             * @param groupId the group ID
27091             * @param urlTitle the url title
27092             * @param status the status
27093             * @param start the lower bound of the range of journal articles
27094             * @param end the upper bound of the range of journal articles (not inclusive)
27095             * @return the range of matching journal articles
27096             * @throws SystemException if a system exception occurred
27097             */
27098            @Override
27099            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27100                    int status, int start, int end) throws SystemException {
27101                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
27102            }
27103    
27104            /**
27105             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27106             *
27107             * <p>
27108             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27109             * </p>
27110             *
27111             * @param groupId the group ID
27112             * @param urlTitle the url title
27113             * @param status the status
27114             * @param start the lower bound of the range of journal articles
27115             * @param end the upper bound of the range of journal articles (not inclusive)
27116             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27117             * @return the ordered range of matching journal articles
27118             * @throws SystemException if a system exception occurred
27119             */
27120            @Override
27121            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27122                    int status, int start, int end, OrderByComparator orderByComparator)
27123                    throws SystemException {
27124                    boolean pagination = true;
27125                    FinderPath finderPath = null;
27126                    Object[] finderArgs = null;
27127    
27128                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
27129                                    (orderByComparator == null)) {
27130                            pagination = false;
27131                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
27132                            finderArgs = new Object[] { groupId, urlTitle, status };
27133                    }
27134                    else {
27135                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
27136                            finderArgs = new Object[] {
27137                                            groupId, urlTitle, status,
27138                                            
27139                                            start, end, orderByComparator
27140                                    };
27141                    }
27142    
27143                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
27144                                    finderArgs, this);
27145    
27146                    if ((list != null) && !list.isEmpty()) {
27147                            for (JournalArticle journalArticle : list) {
27148                                    if ((groupId != journalArticle.getGroupId()) ||
27149                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
27150                                                    (status != journalArticle.getStatus())) {
27151                                            list = null;
27152    
27153                                            break;
27154                                    }
27155                            }
27156                    }
27157    
27158                    if (list == null) {
27159                            StringBundler query = null;
27160    
27161                            if (orderByComparator != null) {
27162                                    query = new StringBundler(5 +
27163                                                    (orderByComparator.getOrderByFields().length * 3));
27164                            }
27165                            else {
27166                                    query = new StringBundler(5);
27167                            }
27168    
27169                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27170    
27171                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27172    
27173                            boolean bindUrlTitle = false;
27174    
27175                            if (urlTitle == null) {
27176                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27177                            }
27178                            else if (urlTitle.equals(StringPool.BLANK)) {
27179                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27180                            }
27181                            else {
27182                                    bindUrlTitle = true;
27183    
27184                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27185                            }
27186    
27187                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27188    
27189                            if (orderByComparator != null) {
27190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27191                                            orderByComparator);
27192                            }
27193                            else
27194                             if (pagination) {
27195                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27196                            }
27197    
27198                            String sql = query.toString();
27199    
27200                            Session session = null;
27201    
27202                            try {
27203                                    session = openSession();
27204    
27205                                    Query q = session.createQuery(sql);
27206    
27207                                    QueryPos qPos = QueryPos.getInstance(q);
27208    
27209                                    qPos.add(groupId);
27210    
27211                                    if (bindUrlTitle) {
27212                                            qPos.add(urlTitle);
27213                                    }
27214    
27215                                    qPos.add(status);
27216    
27217                                    if (!pagination) {
27218                                            list = (List<JournalArticle>)QueryUtil.list(q,
27219                                                            getDialect(), start, end, false);
27220    
27221                                            Collections.sort(list);
27222    
27223                                            list = new UnmodifiableList<JournalArticle>(list);
27224                                    }
27225                                    else {
27226                                            list = (List<JournalArticle>)QueryUtil.list(q,
27227                                                            getDialect(), start, end);
27228                                    }
27229    
27230                                    cacheResult(list);
27231    
27232                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
27233                            }
27234                            catch (Exception e) {
27235                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27236    
27237                                    throw processException(e);
27238                            }
27239                            finally {
27240                                    closeSession(session);
27241                            }
27242                    }
27243    
27244                    return list;
27245            }
27246    
27247            /**
27248             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27249             *
27250             * @param groupId the group ID
27251             * @param urlTitle the url title
27252             * @param status the status
27253             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27254             * @return the first matching journal article
27255             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27256             * @throws SystemException if a system exception occurred
27257             */
27258            @Override
27259            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
27260                    int status, OrderByComparator orderByComparator)
27261                    throws NoSuchArticleException, SystemException {
27262                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
27263                                    status, orderByComparator);
27264    
27265                    if (journalArticle != null) {
27266                            return journalArticle;
27267                    }
27268    
27269                    StringBundler msg = new StringBundler(8);
27270    
27271                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27272    
27273                    msg.append("groupId=");
27274                    msg.append(groupId);
27275    
27276                    msg.append(", urlTitle=");
27277                    msg.append(urlTitle);
27278    
27279                    msg.append(", status=");
27280                    msg.append(status);
27281    
27282                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27283    
27284                    throw new NoSuchArticleException(msg.toString());
27285            }
27286    
27287            /**
27288             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27289             *
27290             * @param groupId the group ID
27291             * @param urlTitle the url title
27292             * @param status the status
27293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27294             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
27295             * @throws SystemException if a system exception occurred
27296             */
27297            @Override
27298            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
27299                    int status, OrderByComparator orderByComparator)
27300                    throws SystemException {
27301                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
27302                                    1, orderByComparator);
27303    
27304                    if (!list.isEmpty()) {
27305                            return list.get(0);
27306                    }
27307    
27308                    return null;
27309            }
27310    
27311            /**
27312             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27313             *
27314             * @param groupId the group ID
27315             * @param urlTitle the url title
27316             * @param status the status
27317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27318             * @return the last matching journal article
27319             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27320             * @throws SystemException if a system exception occurred
27321             */
27322            @Override
27323            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
27324                    int status, OrderByComparator orderByComparator)
27325                    throws NoSuchArticleException, SystemException {
27326                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
27327                                    status, orderByComparator);
27328    
27329                    if (journalArticle != null) {
27330                            return journalArticle;
27331                    }
27332    
27333                    StringBundler msg = new StringBundler(8);
27334    
27335                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27336    
27337                    msg.append("groupId=");
27338                    msg.append(groupId);
27339    
27340                    msg.append(", urlTitle=");
27341                    msg.append(urlTitle);
27342    
27343                    msg.append(", status=");
27344                    msg.append(status);
27345    
27346                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27347    
27348                    throw new NoSuchArticleException(msg.toString());
27349            }
27350    
27351            /**
27352             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27353             *
27354             * @param groupId the group ID
27355             * @param urlTitle the url title
27356             * @param status the status
27357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27358             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
27359             * @throws SystemException if a system exception occurred
27360             */
27361            @Override
27362            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
27363                    int status, OrderByComparator orderByComparator)
27364                    throws SystemException {
27365                    int count = countByG_UT_ST(groupId, urlTitle, status);
27366    
27367                    if (count == 0) {
27368                            return null;
27369                    }
27370    
27371                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
27372                                    count - 1, count, orderByComparator);
27373    
27374                    if (!list.isEmpty()) {
27375                            return list.get(0);
27376                    }
27377    
27378                    return null;
27379            }
27380    
27381            /**
27382             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27383             *
27384             * @param id the primary key of the current journal article
27385             * @param groupId the group ID
27386             * @param urlTitle the url title
27387             * @param status the status
27388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27389             * @return the previous, current, and next journal article
27390             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27391             * @throws SystemException if a system exception occurred
27392             */
27393            @Override
27394            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
27395                    String urlTitle, int status, OrderByComparator orderByComparator)
27396                    throws NoSuchArticleException, SystemException {
27397                    JournalArticle journalArticle = findByPrimaryKey(id);
27398    
27399                    Session session = null;
27400    
27401                    try {
27402                            session = openSession();
27403    
27404                            JournalArticle[] array = new JournalArticleImpl[3];
27405    
27406                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
27407                                            groupId, urlTitle, status, orderByComparator, true);
27408    
27409                            array[1] = journalArticle;
27410    
27411                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
27412                                            groupId, urlTitle, status, orderByComparator, false);
27413    
27414                            return array;
27415                    }
27416                    catch (Exception e) {
27417                            throw processException(e);
27418                    }
27419                    finally {
27420                            closeSession(session);
27421                    }
27422            }
27423    
27424            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
27425                    JournalArticle journalArticle, long groupId, String urlTitle,
27426                    int status, OrderByComparator orderByComparator, boolean previous) {
27427                    StringBundler query = null;
27428    
27429                    if (orderByComparator != null) {
27430                            query = new StringBundler(6 +
27431                                            (orderByComparator.getOrderByFields().length * 6));
27432                    }
27433                    else {
27434                            query = new StringBundler(3);
27435                    }
27436    
27437                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27438    
27439                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27440    
27441                    boolean bindUrlTitle = false;
27442    
27443                    if (urlTitle == null) {
27444                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27445                    }
27446                    else if (urlTitle.equals(StringPool.BLANK)) {
27447                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27448                    }
27449                    else {
27450                            bindUrlTitle = true;
27451    
27452                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27453                    }
27454    
27455                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27456    
27457                    if (orderByComparator != null) {
27458                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27459    
27460                            if (orderByConditionFields.length > 0) {
27461                                    query.append(WHERE_AND);
27462                            }
27463    
27464                            for (int i = 0; i < orderByConditionFields.length; i++) {
27465                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27466                                    query.append(orderByConditionFields[i]);
27467    
27468                                    if ((i + 1) < orderByConditionFields.length) {
27469                                            if (orderByComparator.isAscending() ^ previous) {
27470                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27471                                            }
27472                                            else {
27473                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27474                                            }
27475                                    }
27476                                    else {
27477                                            if (orderByComparator.isAscending() ^ previous) {
27478                                                    query.append(WHERE_GREATER_THAN);
27479                                            }
27480                                            else {
27481                                                    query.append(WHERE_LESSER_THAN);
27482                                            }
27483                                    }
27484                            }
27485    
27486                            query.append(ORDER_BY_CLAUSE);
27487    
27488                            String[] orderByFields = orderByComparator.getOrderByFields();
27489    
27490                            for (int i = 0; i < orderByFields.length; i++) {
27491                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27492                                    query.append(orderByFields[i]);
27493    
27494                                    if ((i + 1) < orderByFields.length) {
27495                                            if (orderByComparator.isAscending() ^ previous) {
27496                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27497                                            }
27498                                            else {
27499                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27500                                            }
27501                                    }
27502                                    else {
27503                                            if (orderByComparator.isAscending() ^ previous) {
27504                                                    query.append(ORDER_BY_ASC);
27505                                            }
27506                                            else {
27507                                                    query.append(ORDER_BY_DESC);
27508                                            }
27509                                    }
27510                            }
27511                    }
27512                    else {
27513                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27514                    }
27515    
27516                    String sql = query.toString();
27517    
27518                    Query q = session.createQuery(sql);
27519    
27520                    q.setFirstResult(0);
27521                    q.setMaxResults(2);
27522    
27523                    QueryPos qPos = QueryPos.getInstance(q);
27524    
27525                    qPos.add(groupId);
27526    
27527                    if (bindUrlTitle) {
27528                            qPos.add(urlTitle);
27529                    }
27530    
27531                    qPos.add(status);
27532    
27533                    if (orderByComparator != null) {
27534                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27535    
27536                            for (Object value : values) {
27537                                    qPos.add(value);
27538                            }
27539                    }
27540    
27541                    List<JournalArticle> list = q.list();
27542    
27543                    if (list.size() == 2) {
27544                            return list.get(1);
27545                    }
27546                    else {
27547                            return null;
27548                    }
27549            }
27550    
27551            /**
27552             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27553             *
27554             * @param groupId the group ID
27555             * @param urlTitle the url title
27556             * @param status the status
27557             * @return the matching journal articles that the user has permission to view
27558             * @throws SystemException if a system exception occurred
27559             */
27560            @Override
27561            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27562                    String urlTitle, int status) throws SystemException {
27563                    return filterFindByG_UT_ST(groupId, urlTitle, status,
27564                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27565            }
27566    
27567            /**
27568             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27569             *
27570             * <p>
27571             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27572             * </p>
27573             *
27574             * @param groupId the group ID
27575             * @param urlTitle the url title
27576             * @param status the status
27577             * @param start the lower bound of the range of journal articles
27578             * @param end the upper bound of the range of journal articles (not inclusive)
27579             * @return the range of matching journal articles that the user has permission to view
27580             * @throws SystemException if a system exception occurred
27581             */
27582            @Override
27583            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27584                    String urlTitle, int status, int start, int end)
27585                    throws SystemException {
27586                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
27587            }
27588    
27589            /**
27590             * 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;.
27591             *
27592             * <p>
27593             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27594             * </p>
27595             *
27596             * @param groupId the group ID
27597             * @param urlTitle the url title
27598             * @param status the status
27599             * @param start the lower bound of the range of journal articles
27600             * @param end the upper bound of the range of journal articles (not inclusive)
27601             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27602             * @return the ordered range of matching journal articles that the user has permission to view
27603             * @throws SystemException if a system exception occurred
27604             */
27605            @Override
27606            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27607                    String urlTitle, int status, int start, int end,
27608                    OrderByComparator orderByComparator) throws SystemException {
27609                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27610                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
27611                                    orderByComparator);
27612                    }
27613    
27614                    StringBundler query = null;
27615    
27616                    if (orderByComparator != null) {
27617                            query = new StringBundler(5 +
27618                                            (orderByComparator.getOrderByFields().length * 3));
27619                    }
27620                    else {
27621                            query = new StringBundler(5);
27622                    }
27623    
27624                    if (getDB().isSupportsInlineDistinct()) {
27625                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27626                    }
27627                    else {
27628                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27629                    }
27630    
27631                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27632    
27633                    boolean bindUrlTitle = false;
27634    
27635                    if (urlTitle == null) {
27636                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27637                    }
27638                    else if (urlTitle.equals(StringPool.BLANK)) {
27639                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27640                    }
27641                    else {
27642                            bindUrlTitle = true;
27643    
27644                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27645                    }
27646    
27647                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27648    
27649                    if (!getDB().isSupportsInlineDistinct()) {
27650                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27651                    }
27652    
27653                    if (orderByComparator != null) {
27654                            if (getDB().isSupportsInlineDistinct()) {
27655                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27656                                            orderByComparator, true);
27657                            }
27658                            else {
27659                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
27660                                            orderByComparator, true);
27661                            }
27662                    }
27663                    else {
27664                            if (getDB().isSupportsInlineDistinct()) {
27665                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27666                            }
27667                            else {
27668                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27669                            }
27670                    }
27671    
27672                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27673                                    JournalArticle.class.getName(),
27674                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27675    
27676                    Session session = null;
27677    
27678                    try {
27679                            session = openSession();
27680    
27681                            SQLQuery q = session.createSQLQuery(sql);
27682    
27683                            if (getDB().isSupportsInlineDistinct()) {
27684                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27685                            }
27686                            else {
27687                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27688                            }
27689    
27690                            QueryPos qPos = QueryPos.getInstance(q);
27691    
27692                            qPos.add(groupId);
27693    
27694                            if (bindUrlTitle) {
27695                                    qPos.add(urlTitle);
27696                            }
27697    
27698                            qPos.add(status);
27699    
27700                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
27701                                    end);
27702                    }
27703                    catch (Exception e) {
27704                            throw processException(e);
27705                    }
27706                    finally {
27707                            closeSession(session);
27708                    }
27709            }
27710    
27711            /**
27712             * 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;.
27713             *
27714             * @param id the primary key of the current journal article
27715             * @param groupId the group ID
27716             * @param urlTitle the url title
27717             * @param status the status
27718             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27719             * @return the previous, current, and next journal article
27720             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27721             * @throws SystemException if a system exception occurred
27722             */
27723            @Override
27724            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
27725                    long groupId, String urlTitle, int status,
27726                    OrderByComparator orderByComparator)
27727                    throws NoSuchArticleException, SystemException {
27728                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27729                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
27730                                    orderByComparator);
27731                    }
27732    
27733                    JournalArticle journalArticle = findByPrimaryKey(id);
27734    
27735                    Session session = null;
27736    
27737                    try {
27738                            session = openSession();
27739    
27740                            JournalArticle[] array = new JournalArticleImpl[3];
27741    
27742                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
27743                                            groupId, urlTitle, status, orderByComparator, true);
27744    
27745                            array[1] = journalArticle;
27746    
27747                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
27748                                            groupId, urlTitle, status, orderByComparator, false);
27749    
27750                            return array;
27751                    }
27752                    catch (Exception e) {
27753                            throw processException(e);
27754                    }
27755                    finally {
27756                            closeSession(session);
27757                    }
27758            }
27759    
27760            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
27761                    JournalArticle journalArticle, long groupId, String urlTitle,
27762                    int status, OrderByComparator orderByComparator, boolean previous) {
27763                    StringBundler query = null;
27764    
27765                    if (orderByComparator != null) {
27766                            query = new StringBundler(6 +
27767                                            (orderByComparator.getOrderByFields().length * 6));
27768                    }
27769                    else {
27770                            query = new StringBundler(3);
27771                    }
27772    
27773                    if (getDB().isSupportsInlineDistinct()) {
27774                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27775                    }
27776                    else {
27777                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27778                    }
27779    
27780                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27781    
27782                    boolean bindUrlTitle = false;
27783    
27784                    if (urlTitle == null) {
27785                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27786                    }
27787                    else if (urlTitle.equals(StringPool.BLANK)) {
27788                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27789                    }
27790                    else {
27791                            bindUrlTitle = true;
27792    
27793                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27794                    }
27795    
27796                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27797    
27798                    if (!getDB().isSupportsInlineDistinct()) {
27799                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27800                    }
27801    
27802                    if (orderByComparator != null) {
27803                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27804    
27805                            if (orderByConditionFields.length > 0) {
27806                                    query.append(WHERE_AND);
27807                            }
27808    
27809                            for (int i = 0; i < orderByConditionFields.length; i++) {
27810                                    if (getDB().isSupportsInlineDistinct()) {
27811                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27812                                    }
27813                                    else {
27814                                            query.append(_ORDER_BY_ENTITY_TABLE);
27815                                    }
27816    
27817                                    query.append(orderByConditionFields[i]);
27818    
27819                                    if ((i + 1) < orderByConditionFields.length) {
27820                                            if (orderByComparator.isAscending() ^ previous) {
27821                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27822                                            }
27823                                            else {
27824                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27825                                            }
27826                                    }
27827                                    else {
27828                                            if (orderByComparator.isAscending() ^ previous) {
27829                                                    query.append(WHERE_GREATER_THAN);
27830                                            }
27831                                            else {
27832                                                    query.append(WHERE_LESSER_THAN);
27833                                            }
27834                                    }
27835                            }
27836    
27837                            query.append(ORDER_BY_CLAUSE);
27838    
27839                            String[] orderByFields = orderByComparator.getOrderByFields();
27840    
27841                            for (int i = 0; i < orderByFields.length; i++) {
27842                                    if (getDB().isSupportsInlineDistinct()) {
27843                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27844                                    }
27845                                    else {
27846                                            query.append(_ORDER_BY_ENTITY_TABLE);
27847                                    }
27848    
27849                                    query.append(orderByFields[i]);
27850    
27851                                    if ((i + 1) < orderByFields.length) {
27852                                            if (orderByComparator.isAscending() ^ previous) {
27853                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27854                                            }
27855                                            else {
27856                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27857                                            }
27858                                    }
27859                                    else {
27860                                            if (orderByComparator.isAscending() ^ previous) {
27861                                                    query.append(ORDER_BY_ASC);
27862                                            }
27863                                            else {
27864                                                    query.append(ORDER_BY_DESC);
27865                                            }
27866                                    }
27867                            }
27868                    }
27869                    else {
27870                            if (getDB().isSupportsInlineDistinct()) {
27871                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27872                            }
27873                            else {
27874                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27875                            }
27876                    }
27877    
27878                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27879                                    JournalArticle.class.getName(),
27880                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27881    
27882                    SQLQuery q = session.createSQLQuery(sql);
27883    
27884                    q.setFirstResult(0);
27885                    q.setMaxResults(2);
27886    
27887                    if (getDB().isSupportsInlineDistinct()) {
27888                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27889                    }
27890                    else {
27891                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27892                    }
27893    
27894                    QueryPos qPos = QueryPos.getInstance(q);
27895    
27896                    qPos.add(groupId);
27897    
27898                    if (bindUrlTitle) {
27899                            qPos.add(urlTitle);
27900                    }
27901    
27902                    qPos.add(status);
27903    
27904                    if (orderByComparator != null) {
27905                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27906    
27907                            for (Object value : values) {
27908                                    qPos.add(value);
27909                            }
27910                    }
27911    
27912                    List<JournalArticle> list = q.list();
27913    
27914                    if (list.size() == 2) {
27915                            return list.get(1);
27916                    }
27917                    else {
27918                            return null;
27919                    }
27920            }
27921    
27922            /**
27923             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
27924             *
27925             * @param groupId the group ID
27926             * @param urlTitle the url title
27927             * @param status the status
27928             * @throws SystemException if a system exception occurred
27929             */
27930            @Override
27931            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
27932                    throws SystemException {
27933                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
27934                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
27935                            remove(journalArticle);
27936                    }
27937            }
27938    
27939            /**
27940             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27941             *
27942             * @param groupId the group ID
27943             * @param urlTitle the url title
27944             * @param status the status
27945             * @return the number of matching journal articles
27946             * @throws SystemException if a system exception occurred
27947             */
27948            @Override
27949            public int countByG_UT_ST(long groupId, String urlTitle, int status)
27950                    throws SystemException {
27951                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
27952    
27953                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
27954    
27955                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
27956                                    this);
27957    
27958                    if (count == null) {
27959                            StringBundler query = new StringBundler(4);
27960    
27961                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
27962    
27963                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27964    
27965                            boolean bindUrlTitle = false;
27966    
27967                            if (urlTitle == null) {
27968                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27969                            }
27970                            else if (urlTitle.equals(StringPool.BLANK)) {
27971                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27972                            }
27973                            else {
27974                                    bindUrlTitle = true;
27975    
27976                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27977                            }
27978    
27979                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27980    
27981                            String sql = query.toString();
27982    
27983                            Session session = null;
27984    
27985                            try {
27986                                    session = openSession();
27987    
27988                                    Query q = session.createQuery(sql);
27989    
27990                                    QueryPos qPos = QueryPos.getInstance(q);
27991    
27992                                    qPos.add(groupId);
27993    
27994                                    if (bindUrlTitle) {
27995                                            qPos.add(urlTitle);
27996                                    }
27997    
27998                                    qPos.add(status);
27999    
28000                                    count = (Long)q.uniqueResult();
28001    
28002                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28003                            }
28004                            catch (Exception e) {
28005                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28006    
28007                                    throw processException(e);
28008                            }
28009                            finally {
28010                                    closeSession(session);
28011                            }
28012                    }
28013    
28014                    return count.intValue();
28015            }
28016    
28017            /**
28018             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28019             *
28020             * @param groupId the group ID
28021             * @param urlTitle the url title
28022             * @param status the status
28023             * @return the number of matching journal articles that the user has permission to view
28024             * @throws SystemException if a system exception occurred
28025             */
28026            @Override
28027            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
28028                    throws SystemException {
28029                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28030                            return countByG_UT_ST(groupId, urlTitle, status);
28031                    }
28032    
28033                    StringBundler query = new StringBundler(4);
28034    
28035                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
28036    
28037                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28038    
28039                    boolean bindUrlTitle = false;
28040    
28041                    if (urlTitle == null) {
28042                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28043                    }
28044                    else if (urlTitle.equals(StringPool.BLANK)) {
28045                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28046                    }
28047                    else {
28048                            bindUrlTitle = true;
28049    
28050                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28051                    }
28052    
28053                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28054    
28055                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28056                                    JournalArticle.class.getName(),
28057                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28058    
28059                    Session session = null;
28060    
28061                    try {
28062                            session = openSession();
28063    
28064                            SQLQuery q = session.createSQLQuery(sql);
28065    
28066                            q.addScalar(COUNT_COLUMN_NAME,
28067                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
28068    
28069                            QueryPos qPos = QueryPos.getInstance(q);
28070    
28071                            qPos.add(groupId);
28072    
28073                            if (bindUrlTitle) {
28074                                    qPos.add(urlTitle);
28075                            }
28076    
28077                            qPos.add(status);
28078    
28079                            Long count = (Long)q.uniqueResult();
28080    
28081                            return count.intValue();
28082                    }
28083                    catch (Exception e) {
28084                            throw processException(e);
28085                    }
28086                    finally {
28087                            closeSession(session);
28088                    }
28089            }
28090    
28091            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
28092            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
28093            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
28094            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
28095            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
28096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28097                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28098                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
28099                            "findByC_V_ST",
28100                            new String[] {
28101                                    Long.class.getName(), Double.class.getName(),
28102                                    Integer.class.getName(),
28103                                    
28104                            Integer.class.getName(), Integer.class.getName(),
28105                                    OrderByComparator.class.getName()
28106                            });
28107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
28108                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28109                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28110                            JournalArticleImpl.class,
28111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
28112                            new String[] {
28113                                    Long.class.getName(), Double.class.getName(),
28114                                    Integer.class.getName()
28115                            },
28116                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
28117                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
28118                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
28119                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
28120            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28121                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
28122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
28123                            new String[] {
28124                                    Long.class.getName(), Double.class.getName(),
28125                                    Integer.class.getName()
28126                            });
28127    
28128            /**
28129             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28130             *
28131             * @param companyId the company ID
28132             * @param version the version
28133             * @param status the status
28134             * @return the matching journal articles
28135             * @throws SystemException if a system exception occurred
28136             */
28137            @Override
28138            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28139                    int status) throws SystemException {
28140                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
28141                            QueryUtil.ALL_POS, null);
28142            }
28143    
28144            /**
28145             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28146             *
28147             * <p>
28148             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28149             * </p>
28150             *
28151             * @param companyId the company ID
28152             * @param version the version
28153             * @param status the status
28154             * @param start the lower bound of the range of journal articles
28155             * @param end the upper bound of the range of journal articles (not inclusive)
28156             * @return the range of matching journal articles
28157             * @throws SystemException if a system exception occurred
28158             */
28159            @Override
28160            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28161                    int status, int start, int end) throws SystemException {
28162                    return findByC_V_ST(companyId, version, status, start, end, null);
28163            }
28164    
28165            /**
28166             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28167             *
28168             * <p>
28169             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28170             * </p>
28171             *
28172             * @param companyId the company ID
28173             * @param version the version
28174             * @param status the status
28175             * @param start the lower bound of the range of journal articles
28176             * @param end the upper bound of the range of journal articles (not inclusive)
28177             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28178             * @return the ordered range of matching journal articles
28179             * @throws SystemException if a system exception occurred
28180             */
28181            @Override
28182            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28183                    int status, int start, int end, OrderByComparator orderByComparator)
28184                    throws SystemException {
28185                    boolean pagination = true;
28186                    FinderPath finderPath = null;
28187                    Object[] finderArgs = null;
28188    
28189                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
28190                                    (orderByComparator == null)) {
28191                            pagination = false;
28192                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
28193                            finderArgs = new Object[] { companyId, version, status };
28194                    }
28195                    else {
28196                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
28197                            finderArgs = new Object[] {
28198                                            companyId, version, status,
28199                                            
28200                                            start, end, orderByComparator
28201                                    };
28202                    }
28203    
28204                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
28205                                    finderArgs, this);
28206    
28207                    if ((list != null) && !list.isEmpty()) {
28208                            for (JournalArticle journalArticle : list) {
28209                                    if ((companyId != journalArticle.getCompanyId()) ||
28210                                                    (version != journalArticle.getVersion()) ||
28211                                                    (status != journalArticle.getStatus())) {
28212                                            list = null;
28213    
28214                                            break;
28215                                    }
28216                            }
28217                    }
28218    
28219                    if (list == null) {
28220                            StringBundler query = null;
28221    
28222                            if (orderByComparator != null) {
28223                                    query = new StringBundler(5 +
28224                                                    (orderByComparator.getOrderByFields().length * 3));
28225                            }
28226                            else {
28227                                    query = new StringBundler(5);
28228                            }
28229    
28230                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28231    
28232                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28233    
28234                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28235    
28236                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28237    
28238                            if (orderByComparator != null) {
28239                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28240                                            orderByComparator);
28241                            }
28242                            else
28243                             if (pagination) {
28244                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28245                            }
28246    
28247                            String sql = query.toString();
28248    
28249                            Session session = null;
28250    
28251                            try {
28252                                    session = openSession();
28253    
28254                                    Query q = session.createQuery(sql);
28255    
28256                                    QueryPos qPos = QueryPos.getInstance(q);
28257    
28258                                    qPos.add(companyId);
28259    
28260                                    qPos.add(version);
28261    
28262                                    qPos.add(status);
28263    
28264                                    if (!pagination) {
28265                                            list = (List<JournalArticle>)QueryUtil.list(q,
28266                                                            getDialect(), start, end, false);
28267    
28268                                            Collections.sort(list);
28269    
28270                                            list = new UnmodifiableList<JournalArticle>(list);
28271                                    }
28272                                    else {
28273                                            list = (List<JournalArticle>)QueryUtil.list(q,
28274                                                            getDialect(), start, end);
28275                                    }
28276    
28277                                    cacheResult(list);
28278    
28279                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
28280                            }
28281                            catch (Exception e) {
28282                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28283    
28284                                    throw processException(e);
28285                            }
28286                            finally {
28287                                    closeSession(session);
28288                            }
28289                    }
28290    
28291                    return list;
28292            }
28293    
28294            /**
28295             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28296             *
28297             * @param companyId the company ID
28298             * @param version the version
28299             * @param status the status
28300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28301             * @return the first matching journal article
28302             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28303             * @throws SystemException if a system exception occurred
28304             */
28305            @Override
28306            public JournalArticle findByC_V_ST_First(long companyId, double version,
28307                    int status, OrderByComparator orderByComparator)
28308                    throws NoSuchArticleException, SystemException {
28309                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
28310                                    status, orderByComparator);
28311    
28312                    if (journalArticle != null) {
28313                            return journalArticle;
28314                    }
28315    
28316                    StringBundler msg = new StringBundler(8);
28317    
28318                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28319    
28320                    msg.append("companyId=");
28321                    msg.append(companyId);
28322    
28323                    msg.append(", version=");
28324                    msg.append(version);
28325    
28326                    msg.append(", status=");
28327                    msg.append(status);
28328    
28329                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28330    
28331                    throw new NoSuchArticleException(msg.toString());
28332            }
28333    
28334            /**
28335             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28336             *
28337             * @param companyId the company ID
28338             * @param version the version
28339             * @param status the status
28340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28341             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
28342             * @throws SystemException if a system exception occurred
28343             */
28344            @Override
28345            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
28346                    int status, OrderByComparator orderByComparator)
28347                    throws SystemException {
28348                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
28349                                    1, orderByComparator);
28350    
28351                    if (!list.isEmpty()) {
28352                            return list.get(0);
28353                    }
28354    
28355                    return null;
28356            }
28357    
28358            /**
28359             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28360             *
28361             * @param companyId the company ID
28362             * @param version the version
28363             * @param status the status
28364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28365             * @return the last matching journal article
28366             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28367             * @throws SystemException if a system exception occurred
28368             */
28369            @Override
28370            public JournalArticle findByC_V_ST_Last(long companyId, double version,
28371                    int status, OrderByComparator orderByComparator)
28372                    throws NoSuchArticleException, SystemException {
28373                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
28374                                    status, orderByComparator);
28375    
28376                    if (journalArticle != null) {
28377                            return journalArticle;
28378                    }
28379    
28380                    StringBundler msg = new StringBundler(8);
28381    
28382                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28383    
28384                    msg.append("companyId=");
28385                    msg.append(companyId);
28386    
28387                    msg.append(", version=");
28388                    msg.append(version);
28389    
28390                    msg.append(", status=");
28391                    msg.append(status);
28392    
28393                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28394    
28395                    throw new NoSuchArticleException(msg.toString());
28396            }
28397    
28398            /**
28399             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28400             *
28401             * @param companyId the company ID
28402             * @param version the version
28403             * @param status the status
28404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28405             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
28406             * @throws SystemException if a system exception occurred
28407             */
28408            @Override
28409            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
28410                    int status, OrderByComparator orderByComparator)
28411                    throws SystemException {
28412                    int count = countByC_V_ST(companyId, version, status);
28413    
28414                    if (count == 0) {
28415                            return null;
28416                    }
28417    
28418                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
28419                                    count - 1, count, orderByComparator);
28420    
28421                    if (!list.isEmpty()) {
28422                            return list.get(0);
28423                    }
28424    
28425                    return null;
28426            }
28427    
28428            /**
28429             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28430             *
28431             * @param id the primary key of the current journal article
28432             * @param companyId the company ID
28433             * @param version the version
28434             * @param status the status
28435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28436             * @return the previous, current, and next journal article
28437             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28438             * @throws SystemException if a system exception occurred
28439             */
28440            @Override
28441            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
28442                    double version, int status, OrderByComparator orderByComparator)
28443                    throws NoSuchArticleException, SystemException {
28444                    JournalArticle journalArticle = findByPrimaryKey(id);
28445    
28446                    Session session = null;
28447    
28448                    try {
28449                            session = openSession();
28450    
28451                            JournalArticle[] array = new JournalArticleImpl[3];
28452    
28453                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
28454                                            companyId, version, status, orderByComparator, true);
28455    
28456                            array[1] = journalArticle;
28457    
28458                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
28459                                            companyId, version, status, orderByComparator, false);
28460    
28461                            return array;
28462                    }
28463                    catch (Exception e) {
28464                            throw processException(e);
28465                    }
28466                    finally {
28467                            closeSession(session);
28468                    }
28469            }
28470    
28471            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
28472                    JournalArticle journalArticle, long companyId, double version,
28473                    int status, OrderByComparator orderByComparator, boolean previous) {
28474                    StringBundler query = null;
28475    
28476                    if (orderByComparator != null) {
28477                            query = new StringBundler(6 +
28478                                            (orderByComparator.getOrderByFields().length * 6));
28479                    }
28480                    else {
28481                            query = new StringBundler(3);
28482                    }
28483    
28484                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28485    
28486                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28487    
28488                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28489    
28490                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28491    
28492                    if (orderByComparator != null) {
28493                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28494    
28495                            if (orderByConditionFields.length > 0) {
28496                                    query.append(WHERE_AND);
28497                            }
28498    
28499                            for (int i = 0; i < orderByConditionFields.length; i++) {
28500                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28501                                    query.append(orderByConditionFields[i]);
28502    
28503                                    if ((i + 1) < orderByConditionFields.length) {
28504                                            if (orderByComparator.isAscending() ^ previous) {
28505                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28506                                            }
28507                                            else {
28508                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28509                                            }
28510                                    }
28511                                    else {
28512                                            if (orderByComparator.isAscending() ^ previous) {
28513                                                    query.append(WHERE_GREATER_THAN);
28514                                            }
28515                                            else {
28516                                                    query.append(WHERE_LESSER_THAN);
28517                                            }
28518                                    }
28519                            }
28520    
28521                            query.append(ORDER_BY_CLAUSE);
28522    
28523                            String[] orderByFields = orderByComparator.getOrderByFields();
28524    
28525                            for (int i = 0; i < orderByFields.length; i++) {
28526                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28527                                    query.append(orderByFields[i]);
28528    
28529                                    if ((i + 1) < orderByFields.length) {
28530                                            if (orderByComparator.isAscending() ^ previous) {
28531                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28532                                            }
28533                                            else {
28534                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28535                                            }
28536                                    }
28537                                    else {
28538                                            if (orderByComparator.isAscending() ^ previous) {
28539                                                    query.append(ORDER_BY_ASC);
28540                                            }
28541                                            else {
28542                                                    query.append(ORDER_BY_DESC);
28543                                            }
28544                                    }
28545                            }
28546                    }
28547                    else {
28548                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28549                    }
28550    
28551                    String sql = query.toString();
28552    
28553                    Query q = session.createQuery(sql);
28554    
28555                    q.setFirstResult(0);
28556                    q.setMaxResults(2);
28557    
28558                    QueryPos qPos = QueryPos.getInstance(q);
28559    
28560                    qPos.add(companyId);
28561    
28562                    qPos.add(version);
28563    
28564                    qPos.add(status);
28565    
28566                    if (orderByComparator != null) {
28567                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28568    
28569                            for (Object value : values) {
28570                                    qPos.add(value);
28571                            }
28572                    }
28573    
28574                    List<JournalArticle> list = q.list();
28575    
28576                    if (list.size() == 2) {
28577                            return list.get(1);
28578                    }
28579                    else {
28580                            return null;
28581                    }
28582            }
28583    
28584            /**
28585             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
28586             *
28587             * @param companyId the company ID
28588             * @param version the version
28589             * @param status the status
28590             * @throws SystemException if a system exception occurred
28591             */
28592            @Override
28593            public void removeByC_V_ST(long companyId, double version, int status)
28594                    throws SystemException {
28595                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
28596                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
28597                            remove(journalArticle);
28598                    }
28599            }
28600    
28601            /**
28602             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28603             *
28604             * @param companyId the company ID
28605             * @param version the version
28606             * @param status the status
28607             * @return the number of matching journal articles
28608             * @throws SystemException if a system exception occurred
28609             */
28610            @Override
28611            public int countByC_V_ST(long companyId, double version, int status)
28612                    throws SystemException {
28613                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
28614    
28615                    Object[] finderArgs = new Object[] { companyId, version, status };
28616    
28617                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
28618                                    this);
28619    
28620                    if (count == null) {
28621                            StringBundler query = new StringBundler(4);
28622    
28623                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28624    
28625                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28626    
28627                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28628    
28629                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28630    
28631                            String sql = query.toString();
28632    
28633                            Session session = null;
28634    
28635                            try {
28636                                    session = openSession();
28637    
28638                                    Query q = session.createQuery(sql);
28639    
28640                                    QueryPos qPos = QueryPos.getInstance(q);
28641    
28642                                    qPos.add(companyId);
28643    
28644                                    qPos.add(version);
28645    
28646                                    qPos.add(status);
28647    
28648                                    count = (Long)q.uniqueResult();
28649    
28650                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28651                            }
28652                            catch (Exception e) {
28653                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28654    
28655                                    throw processException(e);
28656                            }
28657                            finally {
28658                                    closeSession(session);
28659                            }
28660                    }
28661    
28662                    return count.intValue();
28663            }
28664    
28665            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
28666            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
28667            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
28668    
28669            public JournalArticlePersistenceImpl() {
28670                    setModelClass(JournalArticle.class);
28671            }
28672    
28673            /**
28674             * Caches the journal article in the entity cache if it is enabled.
28675             *
28676             * @param journalArticle the journal article
28677             */
28678            @Override
28679            public void cacheResult(JournalArticle journalArticle) {
28680                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28681                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
28682                            journalArticle);
28683    
28684                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
28685                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
28686                            journalArticle);
28687    
28688                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
28689                            new Object[] {
28690                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
28691                                    journalArticle.getStructureId()
28692                            }, journalArticle);
28693    
28694                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
28695                            new Object[] {
28696                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
28697                                    journalArticle.getVersion()
28698                            }, journalArticle);
28699    
28700                    journalArticle.resetOriginalValues();
28701            }
28702    
28703            /**
28704             * Caches the journal articles in the entity cache if it is enabled.
28705             *
28706             * @param journalArticles the journal articles
28707             */
28708            @Override
28709            public void cacheResult(List<JournalArticle> journalArticles) {
28710                    for (JournalArticle journalArticle : journalArticles) {
28711                            if (EntityCacheUtil.getResult(
28712                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28713                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
28714                                    cacheResult(journalArticle);
28715                            }
28716                            else {
28717                                    journalArticle.resetOriginalValues();
28718                            }
28719                    }
28720            }
28721    
28722            /**
28723             * Clears the cache for all journal articles.
28724             *
28725             * <p>
28726             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
28727             * </p>
28728             */
28729            @Override
28730            public void clearCache() {
28731                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
28732                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
28733                    }
28734    
28735                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
28736    
28737                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
28738                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28739                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28740            }
28741    
28742            /**
28743             * Clears the cache for the journal article.
28744             *
28745             * <p>
28746             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
28747             * </p>
28748             */
28749            @Override
28750            public void clearCache(JournalArticle journalArticle) {
28751                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28752                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
28753    
28754                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28755                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28756    
28757                    clearUniqueFindersCache(journalArticle);
28758            }
28759    
28760            @Override
28761            public void clearCache(List<JournalArticle> journalArticles) {
28762                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28763                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28764    
28765                    for (JournalArticle journalArticle : journalArticles) {
28766                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28767                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
28768    
28769                            clearUniqueFindersCache(journalArticle);
28770                    }
28771            }
28772    
28773            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
28774                    if (journalArticle.isNew()) {
28775                            Object[] args = new Object[] {
28776                                            journalArticle.getUuid(), journalArticle.getGroupId()
28777                                    };
28778    
28779                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
28780                                    Long.valueOf(1));
28781                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
28782                                    journalArticle);
28783    
28784                            args = new Object[] {
28785                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
28786                                            journalArticle.getStructureId()
28787                                    };
28788    
28789                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
28790                                    Long.valueOf(1));
28791                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
28792                                    journalArticle);
28793    
28794                            args = new Object[] {
28795                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
28796                                            journalArticle.getVersion()
28797                                    };
28798    
28799                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
28800                                    Long.valueOf(1));
28801                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
28802                                    journalArticle);
28803                    }
28804                    else {
28805                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
28806    
28807                            if ((journalArticleModelImpl.getColumnBitmask() &
28808                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
28809                                    Object[] args = new Object[] {
28810                                                    journalArticle.getUuid(), journalArticle.getGroupId()
28811                                            };
28812    
28813                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
28814                                            Long.valueOf(1));
28815                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
28816                                            journalArticle);
28817                            }
28818    
28819                            if ((journalArticleModelImpl.getColumnBitmask() &
28820                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
28821                                    Object[] args = new Object[] {
28822                                                    journalArticle.getGroupId(),
28823                                                    journalArticle.getClassNameId(),
28824                                                    journalArticle.getStructureId()
28825                                            };
28826    
28827                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
28828                                            Long.valueOf(1));
28829                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
28830                                            journalArticle);
28831                            }
28832    
28833                            if ((journalArticleModelImpl.getColumnBitmask() &
28834                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
28835                                    Object[] args = new Object[] {
28836                                                    journalArticle.getGroupId(),
28837                                                    journalArticle.getArticleId(),
28838                                                    journalArticle.getVersion()
28839                                            };
28840    
28841                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
28842                                            Long.valueOf(1));
28843                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
28844                                            journalArticle);
28845                            }
28846                    }
28847            }
28848    
28849            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
28850                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
28851    
28852                    Object[] args = new Object[] {
28853                                    journalArticle.getUuid(), journalArticle.getGroupId()
28854                            };
28855    
28856                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
28857                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
28858    
28859                    if ((journalArticleModelImpl.getColumnBitmask() &
28860                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
28861                            args = new Object[] {
28862                                            journalArticleModelImpl.getOriginalUuid(),
28863                                            journalArticleModelImpl.getOriginalGroupId()
28864                                    };
28865    
28866                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
28867                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
28868                    }
28869    
28870                    args = new Object[] {
28871                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
28872                                    journalArticle.getStructureId()
28873                            };
28874    
28875                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
28876                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
28877    
28878                    if ((journalArticleModelImpl.getColumnBitmask() &
28879                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
28880                            args = new Object[] {
28881                                            journalArticleModelImpl.getOriginalGroupId(),
28882                                            journalArticleModelImpl.getOriginalClassNameId(),
28883                                            journalArticleModelImpl.getOriginalStructureId()
28884                                    };
28885    
28886                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
28887                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
28888                    }
28889    
28890                    args = new Object[] {
28891                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
28892                                    journalArticle.getVersion()
28893                            };
28894    
28895                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
28896                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
28897    
28898                    if ((journalArticleModelImpl.getColumnBitmask() &
28899                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
28900                            args = new Object[] {
28901                                            journalArticleModelImpl.getOriginalGroupId(),
28902                                            journalArticleModelImpl.getOriginalArticleId(),
28903                                            journalArticleModelImpl.getOriginalVersion()
28904                                    };
28905    
28906                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
28907                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
28908                    }
28909            }
28910    
28911            /**
28912             * Creates a new journal article with the primary key. Does not add the journal article to the database.
28913             *
28914             * @param id the primary key for the new journal article
28915             * @return the new journal article
28916             */
28917            @Override
28918            public JournalArticle create(long id) {
28919                    JournalArticle journalArticle = new JournalArticleImpl();
28920    
28921                    journalArticle.setNew(true);
28922                    journalArticle.setPrimaryKey(id);
28923    
28924                    String uuid = PortalUUIDUtil.generate();
28925    
28926                    journalArticle.setUuid(uuid);
28927    
28928                    return journalArticle;
28929            }
28930    
28931            /**
28932             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
28933             *
28934             * @param id the primary key of the journal article
28935             * @return the journal article that was removed
28936             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28937             * @throws SystemException if a system exception occurred
28938             */
28939            @Override
28940            public JournalArticle remove(long id)
28941                    throws NoSuchArticleException, SystemException {
28942                    return remove((Serializable)id);
28943            }
28944    
28945            /**
28946             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
28947             *
28948             * @param primaryKey the primary key of the journal article
28949             * @return the journal article that was removed
28950             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28951             * @throws SystemException if a system exception occurred
28952             */
28953            @Override
28954            public JournalArticle remove(Serializable primaryKey)
28955                    throws NoSuchArticleException, SystemException {
28956                    Session session = null;
28957    
28958                    try {
28959                            session = openSession();
28960    
28961                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
28962                                            primaryKey);
28963    
28964                            if (journalArticle == null) {
28965                                    if (_log.isWarnEnabled()) {
28966                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
28967                                    }
28968    
28969                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
28970                                            primaryKey);
28971                            }
28972    
28973                            return remove(journalArticle);
28974                    }
28975                    catch (NoSuchArticleException nsee) {
28976                            throw nsee;
28977                    }
28978                    catch (Exception e) {
28979                            throw processException(e);
28980                    }
28981                    finally {
28982                            closeSession(session);
28983                    }
28984            }
28985    
28986            @Override
28987            protected JournalArticle removeImpl(JournalArticle journalArticle)
28988                    throws SystemException {
28989                    journalArticle = toUnwrappedModel(journalArticle);
28990    
28991                    Session session = null;
28992    
28993                    try {
28994                            session = openSession();
28995    
28996                            if (!session.contains(journalArticle)) {
28997                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
28998                                                    journalArticle.getPrimaryKeyObj());
28999                            }
29000    
29001                            if (journalArticle != null) {
29002                                    session.delete(journalArticle);
29003                            }
29004                    }
29005                    catch (Exception e) {
29006                            throw processException(e);
29007                    }
29008                    finally {
29009                            closeSession(session);
29010                    }
29011    
29012                    if (journalArticle != null) {
29013                            clearCache(journalArticle);
29014                    }
29015    
29016                    return journalArticle;
29017            }
29018    
29019            @Override
29020            public JournalArticle updateImpl(
29021                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
29022                    throws SystemException {
29023                    journalArticle = toUnwrappedModel(journalArticle);
29024    
29025                    boolean isNew = journalArticle.isNew();
29026    
29027                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29028    
29029                    if (Validator.isNull(journalArticle.getUuid())) {
29030                            String uuid = PortalUUIDUtil.generate();
29031    
29032                            journalArticle.setUuid(uuid);
29033                    }
29034    
29035                    Session session = null;
29036    
29037                    try {
29038                            session = openSession();
29039    
29040                            if (journalArticle.isNew()) {
29041                                    session.save(journalArticle);
29042    
29043                                    journalArticle.setNew(false);
29044                            }
29045                            else {
29046                                    session.merge(journalArticle);
29047                            }
29048                    }
29049                    catch (Exception e) {
29050                            throw processException(e);
29051                    }
29052                    finally {
29053                            closeSession(session);
29054                    }
29055    
29056                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29057    
29058                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
29059                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29060                    }
29061    
29062                    else {
29063                            if ((journalArticleModelImpl.getColumnBitmask() &
29064                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
29065                                    Object[] args = new Object[] {
29066                                                    journalArticleModelImpl.getOriginalUuid()
29067                                            };
29068    
29069                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29070                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29071                                            args);
29072    
29073                                    args = new Object[] { journalArticleModelImpl.getUuid() };
29074    
29075                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29076                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29077                                            args);
29078                            }
29079    
29080                            if ((journalArticleModelImpl.getColumnBitmask() &
29081                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
29082                                    Object[] args = new Object[] {
29083                                                    journalArticleModelImpl.getOriginalUuid(),
29084                                                    journalArticleModelImpl.getOriginalCompanyId()
29085                                            };
29086    
29087                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29088                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29089                                            args);
29090    
29091                                    args = new Object[] {
29092                                                    journalArticleModelImpl.getUuid(),
29093                                                    journalArticleModelImpl.getCompanyId()
29094                                            };
29095    
29096                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29097                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29098                                            args);
29099                            }
29100    
29101                            if ((journalArticleModelImpl.getColumnBitmask() &
29102                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
29103                                    Object[] args = new Object[] {
29104                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
29105                                            };
29106    
29107                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29108                                            args);
29109                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29110                                            args);
29111    
29112                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
29113    
29114                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29115                                            args);
29116                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29117                                            args);
29118                            }
29119    
29120                            if ((journalArticleModelImpl.getColumnBitmask() &
29121                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
29122                                    Object[] args = new Object[] {
29123                                                    journalArticleModelImpl.getOriginalGroupId()
29124                                            };
29125    
29126                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
29127                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
29128                                            args);
29129    
29130                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
29131    
29132                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
29133                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
29134                                            args);
29135                            }
29136    
29137                            if ((journalArticleModelImpl.getColumnBitmask() &
29138                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
29139                                    Object[] args = new Object[] {
29140                                                    journalArticleModelImpl.getOriginalCompanyId()
29141                                            };
29142    
29143                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
29144                                            args);
29145                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
29146                                            args);
29147    
29148                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
29149    
29150                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
29151                                            args);
29152                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
29153                                            args);
29154                            }
29155    
29156                            if ((journalArticleModelImpl.getColumnBitmask() &
29157                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
29158                                    Object[] args = new Object[] {
29159                                                    journalArticleModelImpl.getOriginalStructureId()
29160                                            };
29161    
29162                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
29163                                            args);
29164                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
29165                                            args);
29166    
29167                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
29168    
29169                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
29170                                            args);
29171                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
29172                                            args);
29173                            }
29174    
29175                            if ((journalArticleModelImpl.getColumnBitmask() &
29176                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
29177                                    Object[] args = new Object[] {
29178                                                    journalArticleModelImpl.getOriginalTemplateId()
29179                                            };
29180    
29181                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
29182                                            args);
29183                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
29184                                            args);
29185    
29186                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
29187    
29188                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
29189                                            args);
29190                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
29191                                            args);
29192                            }
29193    
29194                            if ((journalArticleModelImpl.getColumnBitmask() &
29195                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
29196                                    Object[] args = new Object[] {
29197                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29198                                            };
29199    
29200                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
29201                                            args);
29202                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
29203                                            args);
29204    
29205                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
29206    
29207                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
29208                                            args);
29209                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
29210                                            args);
29211                            }
29212    
29213                            if ((journalArticleModelImpl.getColumnBitmask() &
29214                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
29215                                    Object[] args = new Object[] {
29216                                                    journalArticleModelImpl.getOriginalSmallImageId()
29217                                            };
29218    
29219                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
29220                                            args);
29221                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
29222                                            args);
29223    
29224                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
29225    
29226                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
29227                                            args);
29228                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
29229                                            args);
29230                            }
29231    
29232                            if ((journalArticleModelImpl.getColumnBitmask() &
29233                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I.getColumnBitmask()) != 0) {
29234                                    Object[] args = new Object[] {
29235                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29236                                                    journalArticleModelImpl.getOriginalIndexable()
29237                                            };
29238    
29239                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
29240                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
29241                                            args);
29242    
29243                                    args = new Object[] {
29244                                                    journalArticleModelImpl.getResourcePrimKey(),
29245                                                    journalArticleModelImpl.getIndexable()
29246                                            };
29247    
29248                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
29249                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
29250                                            args);
29251                            }
29252    
29253                            if ((journalArticleModelImpl.getColumnBitmask() &
29254                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
29255                                    Object[] args = new Object[] {
29256                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29257                                                    journalArticleModelImpl.getOriginalStatus()
29258                                            };
29259    
29260                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
29261                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
29262                                            args);
29263    
29264                                    args = new Object[] {
29265                                                    journalArticleModelImpl.getResourcePrimKey(),
29266                                                    journalArticleModelImpl.getStatus()
29267                                            };
29268    
29269                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
29270                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
29271                                            args);
29272                            }
29273    
29274                            if ((journalArticleModelImpl.getColumnBitmask() &
29275                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
29276                                    Object[] args = new Object[] {
29277                                                    journalArticleModelImpl.getOriginalGroupId(),
29278                                                    journalArticleModelImpl.getOriginalUserId()
29279                                            };
29280    
29281                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
29282                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
29283                                            args);
29284    
29285                                    args = new Object[] {
29286                                                    journalArticleModelImpl.getGroupId(),
29287                                                    journalArticleModelImpl.getUserId()
29288                                            };
29289    
29290                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
29291                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
29292                                            args);
29293                            }
29294    
29295                            if ((journalArticleModelImpl.getColumnBitmask() &
29296                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
29297                                    Object[] args = new Object[] {
29298                                                    journalArticleModelImpl.getOriginalGroupId(),
29299                                                    journalArticleModelImpl.getOriginalFolderId()
29300                                            };
29301    
29302                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
29303                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
29304                                            args);
29305    
29306                                    args = new Object[] {
29307                                                    journalArticleModelImpl.getGroupId(),
29308                                                    journalArticleModelImpl.getFolderId()
29309                                            };
29310    
29311                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
29312                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
29313                                            args);
29314                            }
29315    
29316                            if ((journalArticleModelImpl.getColumnBitmask() &
29317                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
29318                                    Object[] args = new Object[] {
29319                                                    journalArticleModelImpl.getOriginalGroupId(),
29320                                                    journalArticleModelImpl.getOriginalArticleId()
29321                                            };
29322    
29323                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
29324                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
29325                                            args);
29326    
29327                                    args = new Object[] {
29328                                                    journalArticleModelImpl.getGroupId(),
29329                                                    journalArticleModelImpl.getArticleId()
29330                                            };
29331    
29332                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
29333                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
29334                                            args);
29335                            }
29336    
29337                            if ((journalArticleModelImpl.getColumnBitmask() &
29338                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
29339                                    Object[] args = new Object[] {
29340                                                    journalArticleModelImpl.getOriginalGroupId(),
29341                                                    journalArticleModelImpl.getOriginalUrlTitle()
29342                                            };
29343    
29344                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
29345                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
29346                                            args);
29347    
29348                                    args = new Object[] {
29349                                                    journalArticleModelImpl.getGroupId(),
29350                                                    journalArticleModelImpl.getUrlTitle()
29351                                            };
29352    
29353                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
29354                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
29355                                            args);
29356                            }
29357    
29358                            if ((journalArticleModelImpl.getColumnBitmask() &
29359                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
29360                                    Object[] args = new Object[] {
29361                                                    journalArticleModelImpl.getOriginalGroupId(),
29362                                                    journalArticleModelImpl.getOriginalStructureId()
29363                                            };
29364    
29365                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
29366                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
29367                                            args);
29368    
29369                                    args = new Object[] {
29370                                                    journalArticleModelImpl.getGroupId(),
29371                                                    journalArticleModelImpl.getStructureId()
29372                                            };
29373    
29374                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
29375                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
29376                                            args);
29377                            }
29378    
29379                            if ((journalArticleModelImpl.getColumnBitmask() &
29380                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
29381                                    Object[] args = new Object[] {
29382                                                    journalArticleModelImpl.getOriginalGroupId(),
29383                                                    journalArticleModelImpl.getOriginalTemplateId()
29384                                            };
29385    
29386                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
29387                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
29388                                            args);
29389    
29390                                    args = new Object[] {
29391                                                    journalArticleModelImpl.getGroupId(),
29392                                                    journalArticleModelImpl.getTemplateId()
29393                                            };
29394    
29395                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
29396                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
29397                                            args);
29398                            }
29399    
29400                            if ((journalArticleModelImpl.getColumnBitmask() &
29401                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
29402                                    Object[] args = new Object[] {
29403                                                    journalArticleModelImpl.getOriginalGroupId(),
29404                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29405                                            };
29406    
29407                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
29408                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
29409                                            args);
29410    
29411                                    args = new Object[] {
29412                                                    journalArticleModelImpl.getGroupId(),
29413                                                    journalArticleModelImpl.getLayoutUuid()
29414                                            };
29415    
29416                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
29417                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
29418                                            args);
29419                            }
29420    
29421                            if ((journalArticleModelImpl.getColumnBitmask() &
29422                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
29423                                    Object[] args = new Object[] {
29424                                                    journalArticleModelImpl.getOriginalGroupId(),
29425                                                    journalArticleModelImpl.getOriginalStatus()
29426                                            };
29427    
29428                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
29429                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
29430                                            args);
29431    
29432                                    args = new Object[] {
29433                                                    journalArticleModelImpl.getGroupId(),
29434                                                    journalArticleModelImpl.getStatus()
29435                                            };
29436    
29437                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
29438                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
29439                                            args);
29440                            }
29441    
29442                            if ((journalArticleModelImpl.getColumnBitmask() &
29443                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
29444                                    Object[] args = new Object[] {
29445                                                    journalArticleModelImpl.getOriginalCompanyId(),
29446                                                    journalArticleModelImpl.getOriginalVersion()
29447                                            };
29448    
29449                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
29450                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
29451                                            args);
29452    
29453                                    args = new Object[] {
29454                                                    journalArticleModelImpl.getCompanyId(),
29455                                                    journalArticleModelImpl.getVersion()
29456                                            };
29457    
29458                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
29459                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
29460                                            args);
29461                            }
29462    
29463                            if ((journalArticleModelImpl.getColumnBitmask() &
29464                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
29465                                    Object[] args = new Object[] {
29466                                                    journalArticleModelImpl.getOriginalCompanyId(),
29467                                                    journalArticleModelImpl.getOriginalStatus()
29468                                            };
29469    
29470                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
29471                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
29472                                            args);
29473    
29474                                    args = new Object[] {
29475                                                    journalArticleModelImpl.getCompanyId(),
29476                                                    journalArticleModelImpl.getStatus()
29477                                            };
29478    
29479                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
29480                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
29481                                            args);
29482                            }
29483    
29484                            if ((journalArticleModelImpl.getColumnBitmask() &
29485                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
29486                                    Object[] args = new Object[] {
29487                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29488                                                    journalArticleModelImpl.getOriginalIndexable(),
29489                                                    journalArticleModelImpl.getOriginalStatus()
29490                                            };
29491    
29492                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
29493                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
29494                                            args);
29495    
29496                                    args = new Object[] {
29497                                                    journalArticleModelImpl.getResourcePrimKey(),
29498                                                    journalArticleModelImpl.getIndexable(),
29499                                                    journalArticleModelImpl.getStatus()
29500                                            };
29501    
29502                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
29503                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
29504                                            args);
29505                            }
29506    
29507                            if ((journalArticleModelImpl.getColumnBitmask() &
29508                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
29509                                    Object[] args = new Object[] {
29510                                                    journalArticleModelImpl.getOriginalGroupId(),
29511                                                    journalArticleModelImpl.getOriginalUserId(),
29512                                                    journalArticleModelImpl.getOriginalClassNameId()
29513                                            };
29514    
29515                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
29516                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
29517                                            args);
29518    
29519                                    args = new Object[] {
29520                                                    journalArticleModelImpl.getGroupId(),
29521                                                    journalArticleModelImpl.getUserId(),
29522                                                    journalArticleModelImpl.getClassNameId()
29523                                            };
29524    
29525                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
29526                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
29527                                            args);
29528                            }
29529    
29530                            if ((journalArticleModelImpl.getColumnBitmask() &
29531                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
29532                                    Object[] args = new Object[] {
29533                                                    journalArticleModelImpl.getOriginalGroupId(),
29534                                                    journalArticleModelImpl.getOriginalFolderId(),
29535                                                    journalArticleModelImpl.getOriginalStatus()
29536                                            };
29537    
29538                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
29539                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
29540                                            args);
29541    
29542                                    args = new Object[] {
29543                                                    journalArticleModelImpl.getGroupId(),
29544                                                    journalArticleModelImpl.getFolderId(),
29545                                                    journalArticleModelImpl.getStatus()
29546                                            };
29547    
29548                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
29549                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
29550                                            args);
29551                            }
29552    
29553                            if ((journalArticleModelImpl.getColumnBitmask() &
29554                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
29555                                    Object[] args = new Object[] {
29556                                                    journalArticleModelImpl.getOriginalGroupId(),
29557                                                    journalArticleModelImpl.getOriginalClassNameId(),
29558                                                    journalArticleModelImpl.getOriginalClassPK()
29559                                            };
29560    
29561                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
29562                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
29563                                            args);
29564    
29565                                    args = new Object[] {
29566                                                    journalArticleModelImpl.getGroupId(),
29567                                                    journalArticleModelImpl.getClassNameId(),
29568                                                    journalArticleModelImpl.getClassPK()
29569                                            };
29570    
29571                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
29572                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
29573                                            args);
29574                            }
29575    
29576                            if ((journalArticleModelImpl.getColumnBitmask() &
29577                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
29578                                    Object[] args = new Object[] {
29579                                                    journalArticleModelImpl.getOriginalGroupId(),
29580                                                    journalArticleModelImpl.getOriginalClassNameId(),
29581                                                    journalArticleModelImpl.getOriginalTemplateId()
29582                                            };
29583    
29584                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
29585                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
29586                                            args);
29587    
29588                                    args = new Object[] {
29589                                                    journalArticleModelImpl.getGroupId(),
29590                                                    journalArticleModelImpl.getClassNameId(),
29591                                                    journalArticleModelImpl.getTemplateId()
29592                                            };
29593    
29594                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
29595                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
29596                                            args);
29597                            }
29598    
29599                            if ((journalArticleModelImpl.getColumnBitmask() &
29600                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
29601                                    Object[] args = new Object[] {
29602                                                    journalArticleModelImpl.getOriginalGroupId(),
29603                                                    journalArticleModelImpl.getOriginalClassNameId(),
29604                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29605                                            };
29606    
29607                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
29608                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
29609                                            args);
29610    
29611                                    args = new Object[] {
29612                                                    journalArticleModelImpl.getGroupId(),
29613                                                    journalArticleModelImpl.getClassNameId(),
29614                                                    journalArticleModelImpl.getLayoutUuid()
29615                                            };
29616    
29617                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
29618                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
29619                                            args);
29620                            }
29621    
29622                            if ((journalArticleModelImpl.getColumnBitmask() &
29623                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
29624                                    Object[] args = new Object[] {
29625                                                    journalArticleModelImpl.getOriginalGroupId(),
29626                                                    journalArticleModelImpl.getOriginalArticleId(),
29627                                                    journalArticleModelImpl.getOriginalStatus()
29628                                            };
29629    
29630                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
29631                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
29632                                            args);
29633    
29634                                    args = new Object[] {
29635                                                    journalArticleModelImpl.getGroupId(),
29636                                                    journalArticleModelImpl.getArticleId(),
29637                                                    journalArticleModelImpl.getStatus()
29638                                            };
29639    
29640                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
29641                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
29642                                            args);
29643                            }
29644    
29645                            if ((journalArticleModelImpl.getColumnBitmask() &
29646                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
29647                                    Object[] args = new Object[] {
29648                                                    journalArticleModelImpl.getOriginalGroupId(),
29649                                                    journalArticleModelImpl.getOriginalUrlTitle(),
29650                                                    journalArticleModelImpl.getOriginalStatus()
29651                                            };
29652    
29653                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
29654                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
29655                                            args);
29656    
29657                                    args = new Object[] {
29658                                                    journalArticleModelImpl.getGroupId(),
29659                                                    journalArticleModelImpl.getUrlTitle(),
29660                                                    journalArticleModelImpl.getStatus()
29661                                            };
29662    
29663                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
29664                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
29665                                            args);
29666                            }
29667    
29668                            if ((journalArticleModelImpl.getColumnBitmask() &
29669                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
29670                                    Object[] args = new Object[] {
29671                                                    journalArticleModelImpl.getOriginalCompanyId(),
29672                                                    journalArticleModelImpl.getOriginalVersion(),
29673                                                    journalArticleModelImpl.getOriginalStatus()
29674                                            };
29675    
29676                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
29677                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
29678                                            args);
29679    
29680                                    args = new Object[] {
29681                                                    journalArticleModelImpl.getCompanyId(),
29682                                                    journalArticleModelImpl.getVersion(),
29683                                                    journalArticleModelImpl.getStatus()
29684                                            };
29685    
29686                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
29687                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
29688                                            args);
29689                            }
29690                    }
29691    
29692                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29693                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
29694                            journalArticle);
29695    
29696                    clearUniqueFindersCache(journalArticle);
29697                    cacheUniqueFindersCache(journalArticle);
29698    
29699                    return journalArticle;
29700            }
29701    
29702            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
29703                    if (journalArticle instanceof JournalArticleImpl) {
29704                            return journalArticle;
29705                    }
29706    
29707                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
29708    
29709                    journalArticleImpl.setNew(journalArticle.isNew());
29710                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
29711    
29712                    journalArticleImpl.setUuid(journalArticle.getUuid());
29713                    journalArticleImpl.setId(journalArticle.getId());
29714                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
29715                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
29716                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
29717                    journalArticleImpl.setUserId(journalArticle.getUserId());
29718                    journalArticleImpl.setUserName(journalArticle.getUserName());
29719                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
29720                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
29721                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
29722                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
29723                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
29724                    journalArticleImpl.setTreePath(journalArticle.getTreePath());
29725                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
29726                    journalArticleImpl.setVersion(journalArticle.getVersion());
29727                    journalArticleImpl.setTitle(journalArticle.getTitle());
29728                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
29729                    journalArticleImpl.setDescription(journalArticle.getDescription());
29730                    journalArticleImpl.setContent(journalArticle.getContent());
29731                    journalArticleImpl.setType(journalArticle.getType());
29732                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
29733                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
29734                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
29735                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
29736                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
29737                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
29738                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
29739                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
29740                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
29741                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
29742                    journalArticleImpl.setStatus(journalArticle.getStatus());
29743                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
29744                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
29745                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
29746    
29747                    return journalArticleImpl;
29748            }
29749    
29750            /**
29751             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
29752             *
29753             * @param primaryKey the primary key of the journal article
29754             * @return the journal article
29755             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29756             * @throws SystemException if a system exception occurred
29757             */
29758            @Override
29759            public JournalArticle findByPrimaryKey(Serializable primaryKey)
29760                    throws NoSuchArticleException, SystemException {
29761                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
29762    
29763                    if (journalArticle == null) {
29764                            if (_log.isWarnEnabled()) {
29765                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
29766                            }
29767    
29768                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
29769                                    primaryKey);
29770                    }
29771    
29772                    return journalArticle;
29773            }
29774    
29775            /**
29776             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
29777             *
29778             * @param id the primary key of the journal article
29779             * @return the journal article
29780             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29781             * @throws SystemException if a system exception occurred
29782             */
29783            @Override
29784            public JournalArticle findByPrimaryKey(long id)
29785                    throws NoSuchArticleException, SystemException {
29786                    return findByPrimaryKey((Serializable)id);
29787            }
29788    
29789            /**
29790             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
29791             *
29792             * @param primaryKey the primary key of the journal article
29793             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
29794             * @throws SystemException if a system exception occurred
29795             */
29796            @Override
29797            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
29798                    throws SystemException {
29799                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29800                                    JournalArticleImpl.class, primaryKey);
29801    
29802                    if (journalArticle == _nullJournalArticle) {
29803                            return null;
29804                    }
29805    
29806                    if (journalArticle == null) {
29807                            Session session = null;
29808    
29809                            try {
29810                                    session = openSession();
29811    
29812                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29813                                                    primaryKey);
29814    
29815                                    if (journalArticle != null) {
29816                                            cacheResult(journalArticle);
29817                                    }
29818                                    else {
29819                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29820                                                    JournalArticleImpl.class, primaryKey,
29821                                                    _nullJournalArticle);
29822                                    }
29823                            }
29824                            catch (Exception e) {
29825                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29826                                            JournalArticleImpl.class, primaryKey);
29827    
29828                                    throw processException(e);
29829                            }
29830                            finally {
29831                                    closeSession(session);
29832                            }
29833                    }
29834    
29835                    return journalArticle;
29836            }
29837    
29838            /**
29839             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
29840             *
29841             * @param id the primary key of the journal article
29842             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
29843             * @throws SystemException if a system exception occurred
29844             */
29845            @Override
29846            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
29847                    return fetchByPrimaryKey((Serializable)id);
29848            }
29849    
29850            /**
29851             * Returns all the journal articles.
29852             *
29853             * @return the journal articles
29854             * @throws SystemException if a system exception occurred
29855             */
29856            @Override
29857            public List<JournalArticle> findAll() throws SystemException {
29858                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
29859            }
29860    
29861            /**
29862             * Returns a range of all the journal articles.
29863             *
29864             * <p>
29865             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
29866             * </p>
29867             *
29868             * @param start the lower bound of the range of journal articles
29869             * @param end the upper bound of the range of journal articles (not inclusive)
29870             * @return the range of journal articles
29871             * @throws SystemException if a system exception occurred
29872             */
29873            @Override
29874            public List<JournalArticle> findAll(int start, int end)
29875                    throws SystemException {
29876                    return findAll(start, end, null);
29877            }
29878    
29879            /**
29880             * Returns an ordered range of all the journal articles.
29881             *
29882             * <p>
29883             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
29884             * </p>
29885             *
29886             * @param start the lower bound of the range of journal articles
29887             * @param end the upper bound of the range of journal articles (not inclusive)
29888             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
29889             * @return the ordered range of journal articles
29890             * @throws SystemException if a system exception occurred
29891             */
29892            @Override
29893            public List<JournalArticle> findAll(int start, int end,
29894                    OrderByComparator orderByComparator) throws SystemException {
29895                    boolean pagination = true;
29896                    FinderPath finderPath = null;
29897                    Object[] finderArgs = null;
29898    
29899                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
29900                                    (orderByComparator == null)) {
29901                            pagination = false;
29902                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
29903                            finderArgs = FINDER_ARGS_EMPTY;
29904                    }
29905                    else {
29906                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
29907                            finderArgs = new Object[] { start, end, orderByComparator };
29908                    }
29909    
29910                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
29911                                    finderArgs, this);
29912    
29913                    if (list == null) {
29914                            StringBundler query = null;
29915                            String sql = null;
29916    
29917                            if (orderByComparator != null) {
29918                                    query = new StringBundler(2 +
29919                                                    (orderByComparator.getOrderByFields().length * 3));
29920    
29921                                    query.append(_SQL_SELECT_JOURNALARTICLE);
29922    
29923                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
29924                                            orderByComparator);
29925    
29926                                    sql = query.toString();
29927                            }
29928                            else {
29929                                    sql = _SQL_SELECT_JOURNALARTICLE;
29930    
29931                                    if (pagination) {
29932                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
29933                                    }
29934                            }
29935    
29936                            Session session = null;
29937    
29938                            try {
29939                                    session = openSession();
29940    
29941                                    Query q = session.createQuery(sql);
29942    
29943                                    if (!pagination) {
29944                                            list = (List<JournalArticle>)QueryUtil.list(q,
29945                                                            getDialect(), start, end, false);
29946    
29947                                            Collections.sort(list);
29948    
29949                                            list = new UnmodifiableList<JournalArticle>(list);
29950                                    }
29951                                    else {
29952                                            list = (List<JournalArticle>)QueryUtil.list(q,
29953                                                            getDialect(), start, end);
29954                                    }
29955    
29956                                    cacheResult(list);
29957    
29958                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
29959                            }
29960                            catch (Exception e) {
29961                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
29962    
29963                                    throw processException(e);
29964                            }
29965                            finally {
29966                                    closeSession(session);
29967                            }
29968                    }
29969    
29970                    return list;
29971            }
29972    
29973            /**
29974             * Removes all the journal articles from the database.
29975             *
29976             * @throws SystemException if a system exception occurred
29977             */
29978            @Override
29979            public void removeAll() throws SystemException {
29980                    for (JournalArticle journalArticle : findAll()) {
29981                            remove(journalArticle);
29982                    }
29983            }
29984    
29985            /**
29986             * Returns the number of journal articles.
29987             *
29988             * @return the number of journal articles
29989             * @throws SystemException if a system exception occurred
29990             */
29991            @Override
29992            public int countAll() throws SystemException {
29993                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
29994                                    FINDER_ARGS_EMPTY, this);
29995    
29996                    if (count == null) {
29997                            Session session = null;
29998    
29999                            try {
30000                                    session = openSession();
30001    
30002                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
30003    
30004                                    count = (Long)q.uniqueResult();
30005    
30006                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
30007                                            FINDER_ARGS_EMPTY, count);
30008                            }
30009                            catch (Exception e) {
30010                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
30011                                            FINDER_ARGS_EMPTY);
30012    
30013                                    throw processException(e);
30014                            }
30015                            finally {
30016                                    closeSession(session);
30017                            }
30018                    }
30019    
30020                    return count.intValue();
30021            }
30022    
30023            @Override
30024            protected Set<String> getBadColumnNames() {
30025                    return _badColumnNames;
30026            }
30027    
30028            /**
30029             * Initializes the journal article persistence.
30030             */
30031            public void afterPropertiesSet() {
30032                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
30033                                            com.liferay.portal.util.PropsUtil.get(
30034                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
30035    
30036                    if (listenerClassNames.length > 0) {
30037                            try {
30038                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
30039    
30040                                    for (String listenerClassName : listenerClassNames) {
30041                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
30042                                                            getClassLoader(), listenerClassName));
30043                                    }
30044    
30045                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
30046                            }
30047                            catch (Exception e) {
30048                                    _log.error(e);
30049                            }
30050                    }
30051            }
30052    
30053            public void destroy() {
30054                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
30055                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
30056                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
30057                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
30058            }
30059    
30060            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
30061            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
30062            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
30063            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
30064            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
30065            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
30066            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
30067                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
30068            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
30069                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
30070            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
30071            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
30072            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
30073            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
30074            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
30075            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
30076            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
30077            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
30078            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
30079            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
30080                                    "uuid", "id", "type"
30081                            });
30082            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
30083                            @Override
30084                            public Object clone() {
30085                                    return this;
30086                            }
30087    
30088                            @Override
30089                            public CacheModel<JournalArticle> toCacheModel() {
30090                                    return _nullJournalArticleCacheModel;
30091                            }
30092                    };
30093    
30094            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
30095                            @Override
30096                            public JournalArticle toEntityModel() {
30097                                    return _nullJournalArticle;
30098                            }
30099                    };
30100    }