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_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5733                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5734                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5735                            "findByR_ST",
5736                            new String[] {
5737                                    Long.class.getName(), Integer.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_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5743                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5744                            JournalArticleImpl.class,
5745                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
5746                            new String[] { Long.class.getName(), Integer.class.getName() },
5747                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5748                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
5749                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5750                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5751            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5752                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5753                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
5754                            new String[] { Long.class.getName(), Integer.class.getName() });
5755    
5756            /**
5757             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5758             *
5759             * @param resourcePrimKey the resource prim key
5760             * @param status the status
5761             * @return the matching journal articles
5762             * @throws SystemException if a system exception occurred
5763             */
5764            @Override
5765            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
5766                    throws SystemException {
5767                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
5768                            QueryUtil.ALL_POS, null);
5769            }
5770    
5771            /**
5772             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#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 status the status
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_ST(long resourcePrimKey, int status,
5787                    int start, int end) throws SystemException {
5788                    return findByR_ST(resourcePrimKey, status, start, end, null);
5789            }
5790    
5791            /**
5792             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#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 status the status
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_ST(long resourcePrimKey, int status,
5808                    int start, int end, OrderByComparator orderByComparator)
5809                    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_ST;
5818                            finderArgs = new Object[] { resourcePrimKey, status };
5819                    }
5820                    else {
5821                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
5822                            finderArgs = new Object[] {
5823                                            resourcePrimKey, status,
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                                                    (status != journalArticle.getStatus())) {
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_ST_RESOURCEPRIMKEY_2);
5857    
5858                            query.append(_FINDER_COLUMN_R_ST_STATUS_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(status);
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 status = &#63;.
5916             *
5917             * @param resourcePrimKey the resource prim key
5918             * @param status the status
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_ST_First(long resourcePrimKey, int status,
5926                    OrderByComparator orderByComparator)
5927                    throws NoSuchArticleException, SystemException {
5928                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
5929                                    status, 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(", status=");
5943                    msg.append(status);
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 status = &#63;.
5952             *
5953             * @param resourcePrimKey the resource prim key
5954             * @param status the status
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_ST_First(long resourcePrimKey, int status,
5961                    OrderByComparator orderByComparator) throws SystemException {
5962                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
5963                                    orderByComparator);
5964    
5965                    if (!list.isEmpty()) {
5966                            return list.get(0);
5967                    }
5968    
5969                    return null;
5970            }
5971    
5972            /**
5973             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5974             *
5975             * @param resourcePrimKey the resource prim key
5976             * @param status the status
5977             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5978             * @return the last matching journal article
5979             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5980             * @throws SystemException if a system exception occurred
5981             */
5982            @Override
5983            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
5984                    OrderByComparator orderByComparator)
5985                    throws NoSuchArticleException, SystemException {
5986                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
5987                                    status, orderByComparator);
5988    
5989                    if (journalArticle != null) {
5990                            return journalArticle;
5991                    }
5992    
5993                    StringBundler msg = new StringBundler(6);
5994    
5995                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5996    
5997                    msg.append("resourcePrimKey=");
5998                    msg.append(resourcePrimKey);
5999    
6000                    msg.append(", status=");
6001                    msg.append(status);
6002    
6003                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6004    
6005                    throw new NoSuchArticleException(msg.toString());
6006            }
6007    
6008            /**
6009             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6010             *
6011             * @param resourcePrimKey the resource prim key
6012             * @param status the status
6013             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6014             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6015             * @throws SystemException if a system exception occurred
6016             */
6017            @Override
6018            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6019                    OrderByComparator orderByComparator) throws SystemException {
6020                    int count = countByR_ST(resourcePrimKey, status);
6021    
6022                    if (count == 0) {
6023                            return null;
6024                    }
6025    
6026                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6027                                    count - 1, count, orderByComparator);
6028    
6029                    if (!list.isEmpty()) {
6030                            return list.get(0);
6031                    }
6032    
6033                    return null;
6034            }
6035    
6036            /**
6037             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6038             *
6039             * @param id the primary key of the current journal article
6040             * @param resourcePrimKey the resource prim key
6041             * @param status the status
6042             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6043             * @return the previous, current, and next journal article
6044             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6045             * @throws SystemException if a system exception occurred
6046             */
6047            @Override
6048            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6049                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
6050                    throws NoSuchArticleException, SystemException {
6051                    JournalArticle journalArticle = findByPrimaryKey(id);
6052    
6053                    Session session = null;
6054    
6055                    try {
6056                            session = openSession();
6057    
6058                            JournalArticle[] array = new JournalArticleImpl[3];
6059    
6060                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6061                                            resourcePrimKey, status, orderByComparator, true);
6062    
6063                            array[1] = journalArticle;
6064    
6065                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6066                                            resourcePrimKey, status, orderByComparator, false);
6067    
6068                            return array;
6069                    }
6070                    catch (Exception e) {
6071                            throw processException(e);
6072                    }
6073                    finally {
6074                            closeSession(session);
6075                    }
6076            }
6077    
6078            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6079                    JournalArticle journalArticle, long resourcePrimKey, int status,
6080                    OrderByComparator orderByComparator, boolean previous) {
6081                    StringBundler query = null;
6082    
6083                    if (orderByComparator != null) {
6084                            query = new StringBundler(6 +
6085                                            (orderByComparator.getOrderByFields().length * 6));
6086                    }
6087                    else {
6088                            query = new StringBundler(3);
6089                    }
6090    
6091                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6092    
6093                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6094    
6095                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6096    
6097                    if (orderByComparator != null) {
6098                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6099    
6100                            if (orderByConditionFields.length > 0) {
6101                                    query.append(WHERE_AND);
6102                            }
6103    
6104                            for (int i = 0; i < orderByConditionFields.length; i++) {
6105                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6106                                    query.append(orderByConditionFields[i]);
6107    
6108                                    if ((i + 1) < orderByConditionFields.length) {
6109                                            if (orderByComparator.isAscending() ^ previous) {
6110                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6111                                            }
6112                                            else {
6113                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6114                                            }
6115                                    }
6116                                    else {
6117                                            if (orderByComparator.isAscending() ^ previous) {
6118                                                    query.append(WHERE_GREATER_THAN);
6119                                            }
6120                                            else {
6121                                                    query.append(WHERE_LESSER_THAN);
6122                                            }
6123                                    }
6124                            }
6125    
6126                            query.append(ORDER_BY_CLAUSE);
6127    
6128                            String[] orderByFields = orderByComparator.getOrderByFields();
6129    
6130                            for (int i = 0; i < orderByFields.length; i++) {
6131                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6132                                    query.append(orderByFields[i]);
6133    
6134                                    if ((i + 1) < orderByFields.length) {
6135                                            if (orderByComparator.isAscending() ^ previous) {
6136                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6137                                            }
6138                                            else {
6139                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6140                                            }
6141                                    }
6142                                    else {
6143                                            if (orderByComparator.isAscending() ^ previous) {
6144                                                    query.append(ORDER_BY_ASC);
6145                                            }
6146                                            else {
6147                                                    query.append(ORDER_BY_DESC);
6148                                            }
6149                                    }
6150                            }
6151                    }
6152                    else {
6153                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6154                    }
6155    
6156                    String sql = query.toString();
6157    
6158                    Query q = session.createQuery(sql);
6159    
6160                    q.setFirstResult(0);
6161                    q.setMaxResults(2);
6162    
6163                    QueryPos qPos = QueryPos.getInstance(q);
6164    
6165                    qPos.add(resourcePrimKey);
6166    
6167                    qPos.add(status);
6168    
6169                    if (orderByComparator != null) {
6170                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6171    
6172                            for (Object value : values) {
6173                                    qPos.add(value);
6174                            }
6175                    }
6176    
6177                    List<JournalArticle> list = q.list();
6178    
6179                    if (list.size() == 2) {
6180                            return list.get(1);
6181                    }
6182                    else {
6183                            return null;
6184                    }
6185            }
6186    
6187            /**
6188             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6189             *
6190             * @param resourcePrimKey the resource prim key
6191             * @param status the status
6192             * @throws SystemException if a system exception occurred
6193             */
6194            @Override
6195            public void removeByR_ST(long resourcePrimKey, int status)
6196                    throws SystemException {
6197                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6198                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6199                            remove(journalArticle);
6200                    }
6201            }
6202    
6203            /**
6204             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6205             *
6206             * @param resourcePrimKey the resource prim key
6207             * @param status the status
6208             * @return the number of matching journal articles
6209             * @throws SystemException if a system exception occurred
6210             */
6211            @Override
6212            public int countByR_ST(long resourcePrimKey, int status)
6213                    throws SystemException {
6214                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6215    
6216                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6217    
6218                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6219                                    this);
6220    
6221                    if (count == null) {
6222                            StringBundler query = new StringBundler(3);
6223    
6224                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6225    
6226                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6227    
6228                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6229    
6230                            String sql = query.toString();
6231    
6232                            Session session = null;
6233    
6234                            try {
6235                                    session = openSession();
6236    
6237                                    Query q = session.createQuery(sql);
6238    
6239                                    QueryPos qPos = QueryPos.getInstance(q);
6240    
6241                                    qPos.add(resourcePrimKey);
6242    
6243                                    qPos.add(status);
6244    
6245                                    count = (Long)q.uniqueResult();
6246    
6247                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6248                            }
6249                            catch (Exception e) {
6250                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6251    
6252                                    throw processException(e);
6253                            }
6254                            finally {
6255                                    closeSession(session);
6256                            }
6257                    }
6258    
6259                    return count.intValue();
6260            }
6261    
6262            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6263            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
6264            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6265                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6266                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6267                            "findByG_U",
6268                            new String[] {
6269                                    Long.class.getName(), Long.class.getName(),
6270                                    
6271                            Integer.class.getName(), Integer.class.getName(),
6272                                    OrderByComparator.class.getName()
6273                            });
6274            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6275                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6276                            JournalArticleImpl.class,
6277                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
6278                            new String[] { Long.class.getName(), Long.class.getName() },
6279                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
6280                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
6281                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6282                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6283            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6284                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6285                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
6286                            new String[] { Long.class.getName(), Long.class.getName() });
6287    
6288            /**
6289             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
6290             *
6291             * @param groupId the group ID
6292             * @param userId the user ID
6293             * @return the matching journal articles
6294             * @throws SystemException if a system exception occurred
6295             */
6296            @Override
6297            public List<JournalArticle> findByG_U(long groupId, long userId)
6298                    throws SystemException {
6299                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6300                            null);
6301            }
6302    
6303            /**
6304             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
6305             *
6306             * <p>
6307             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6308             * </p>
6309             *
6310             * @param groupId the group ID
6311             * @param userId the user ID
6312             * @param start the lower bound of the range of journal articles
6313             * @param end the upper bound of the range of journal articles (not inclusive)
6314             * @return the range of matching journal articles
6315             * @throws SystemException if a system exception occurred
6316             */
6317            @Override
6318            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6319                    int end) throws SystemException {
6320                    return findByG_U(groupId, userId, start, end, null);
6321            }
6322    
6323            /**
6324             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
6325             *
6326             * <p>
6327             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6328             * </p>
6329             *
6330             * @param groupId the group ID
6331             * @param userId the user ID
6332             * @param start the lower bound of the range of journal articles
6333             * @param end the upper bound of the range of journal articles (not inclusive)
6334             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6335             * @return the ordered range of matching journal articles
6336             * @throws SystemException if a system exception occurred
6337             */
6338            @Override
6339            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6340                    int end, OrderByComparator orderByComparator) throws SystemException {
6341                    boolean pagination = true;
6342                    FinderPath finderPath = null;
6343                    Object[] finderArgs = null;
6344    
6345                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6346                                    (orderByComparator == null)) {
6347                            pagination = false;
6348                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
6349                            finderArgs = new Object[] { groupId, userId };
6350                    }
6351                    else {
6352                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
6353                            finderArgs = new Object[] {
6354                                            groupId, userId,
6355                                            
6356                                            start, end, orderByComparator
6357                                    };
6358                    }
6359    
6360                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6361                                    finderArgs, this);
6362    
6363                    if ((list != null) && !list.isEmpty()) {
6364                            for (JournalArticle journalArticle : list) {
6365                                    if ((groupId != journalArticle.getGroupId()) ||
6366                                                    (userId != journalArticle.getUserId())) {
6367                                            list = null;
6368    
6369                                            break;
6370                                    }
6371                            }
6372                    }
6373    
6374                    if (list == null) {
6375                            StringBundler query = null;
6376    
6377                            if (orderByComparator != null) {
6378                                    query = new StringBundler(4 +
6379                                                    (orderByComparator.getOrderByFields().length * 3));
6380                            }
6381                            else {
6382                                    query = new StringBundler(4);
6383                            }
6384    
6385                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6386    
6387                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6388    
6389                            query.append(_FINDER_COLUMN_G_U_USERID_2);
6390    
6391                            if (orderByComparator != null) {
6392                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6393                                            orderByComparator);
6394                            }
6395                            else
6396                             if (pagination) {
6397                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6398                            }
6399    
6400                            String sql = query.toString();
6401    
6402                            Session session = null;
6403    
6404                            try {
6405                                    session = openSession();
6406    
6407                                    Query q = session.createQuery(sql);
6408    
6409                                    QueryPos qPos = QueryPos.getInstance(q);
6410    
6411                                    qPos.add(groupId);
6412    
6413                                    qPos.add(userId);
6414    
6415                                    if (!pagination) {
6416                                            list = (List<JournalArticle>)QueryUtil.list(q,
6417                                                            getDialect(), start, end, false);
6418    
6419                                            Collections.sort(list);
6420    
6421                                            list = new UnmodifiableList<JournalArticle>(list);
6422                                    }
6423                                    else {
6424                                            list = (List<JournalArticle>)QueryUtil.list(q,
6425                                                            getDialect(), start, end);
6426                                    }
6427    
6428                                    cacheResult(list);
6429    
6430                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6431                            }
6432                            catch (Exception e) {
6433                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6434    
6435                                    throw processException(e);
6436                            }
6437                            finally {
6438                                    closeSession(session);
6439                            }
6440                    }
6441    
6442                    return list;
6443            }
6444    
6445            /**
6446             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6447             *
6448             * @param groupId the group ID
6449             * @param userId the user ID
6450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6451             * @return the first matching journal article
6452             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6453             * @throws SystemException if a system exception occurred
6454             */
6455            @Override
6456            public JournalArticle findByG_U_First(long groupId, long userId,
6457                    OrderByComparator orderByComparator)
6458                    throws NoSuchArticleException, SystemException {
6459                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
6460                                    orderByComparator);
6461    
6462                    if (journalArticle != null) {
6463                            return journalArticle;
6464                    }
6465    
6466                    StringBundler msg = new StringBundler(6);
6467    
6468                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6469    
6470                    msg.append("groupId=");
6471                    msg.append(groupId);
6472    
6473                    msg.append(", userId=");
6474                    msg.append(userId);
6475    
6476                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6477    
6478                    throw new NoSuchArticleException(msg.toString());
6479            }
6480    
6481            /**
6482             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6483             *
6484             * @param groupId the group ID
6485             * @param userId the user ID
6486             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6487             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6488             * @throws SystemException if a system exception occurred
6489             */
6490            @Override
6491            public JournalArticle fetchByG_U_First(long groupId, long userId,
6492                    OrderByComparator orderByComparator) throws SystemException {
6493                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
6494                                    orderByComparator);
6495    
6496                    if (!list.isEmpty()) {
6497                            return list.get(0);
6498                    }
6499    
6500                    return null;
6501            }
6502    
6503            /**
6504             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6505             *
6506             * @param groupId the group ID
6507             * @param userId the user ID
6508             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6509             * @return the last matching journal article
6510             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6511             * @throws SystemException if a system exception occurred
6512             */
6513            @Override
6514            public JournalArticle findByG_U_Last(long groupId, long userId,
6515                    OrderByComparator orderByComparator)
6516                    throws NoSuchArticleException, SystemException {
6517                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
6518                                    orderByComparator);
6519    
6520                    if (journalArticle != null) {
6521                            return journalArticle;
6522                    }
6523    
6524                    StringBundler msg = new StringBundler(6);
6525    
6526                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6527    
6528                    msg.append("groupId=");
6529                    msg.append(groupId);
6530    
6531                    msg.append(", userId=");
6532                    msg.append(userId);
6533    
6534                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6535    
6536                    throw new NoSuchArticleException(msg.toString());
6537            }
6538    
6539            /**
6540             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6541             *
6542             * @param groupId the group ID
6543             * @param userId the user ID
6544             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6545             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6546             * @throws SystemException if a system exception occurred
6547             */
6548            @Override
6549            public JournalArticle fetchByG_U_Last(long groupId, long userId,
6550                    OrderByComparator orderByComparator) throws SystemException {
6551                    int count = countByG_U(groupId, userId);
6552    
6553                    if (count == 0) {
6554                            return null;
6555                    }
6556    
6557                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
6558                                    count, orderByComparator);
6559    
6560                    if (!list.isEmpty()) {
6561                            return list.get(0);
6562                    }
6563    
6564                    return null;
6565            }
6566    
6567            /**
6568             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
6569             *
6570             * @param id the primary key of the current journal article
6571             * @param groupId the group ID
6572             * @param userId the user ID
6573             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6574             * @return the previous, current, and next journal article
6575             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6576             * @throws SystemException if a system exception occurred
6577             */
6578            @Override
6579            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
6580                    long userId, OrderByComparator orderByComparator)
6581                    throws NoSuchArticleException, SystemException {
6582                    JournalArticle journalArticle = findByPrimaryKey(id);
6583    
6584                    Session session = null;
6585    
6586                    try {
6587                            session = openSession();
6588    
6589                            JournalArticle[] array = new JournalArticleImpl[3];
6590    
6591                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6592                                            userId, orderByComparator, true);
6593    
6594                            array[1] = journalArticle;
6595    
6596                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6597                                            userId, orderByComparator, false);
6598    
6599                            return array;
6600                    }
6601                    catch (Exception e) {
6602                            throw processException(e);
6603                    }
6604                    finally {
6605                            closeSession(session);
6606                    }
6607            }
6608    
6609            protected JournalArticle getByG_U_PrevAndNext(Session session,
6610                    JournalArticle journalArticle, long groupId, long userId,
6611                    OrderByComparator orderByComparator, boolean previous) {
6612                    StringBundler query = null;
6613    
6614                    if (orderByComparator != null) {
6615                            query = new StringBundler(6 +
6616                                            (orderByComparator.getOrderByFields().length * 6));
6617                    }
6618                    else {
6619                            query = new StringBundler(3);
6620                    }
6621    
6622                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6623    
6624                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6625    
6626                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6627    
6628                    if (orderByComparator != null) {
6629                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6630    
6631                            if (orderByConditionFields.length > 0) {
6632                                    query.append(WHERE_AND);
6633                            }
6634    
6635                            for (int i = 0; i < orderByConditionFields.length; i++) {
6636                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6637                                    query.append(orderByConditionFields[i]);
6638    
6639                                    if ((i + 1) < orderByConditionFields.length) {
6640                                            if (orderByComparator.isAscending() ^ previous) {
6641                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6642                                            }
6643                                            else {
6644                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6645                                            }
6646                                    }
6647                                    else {
6648                                            if (orderByComparator.isAscending() ^ previous) {
6649                                                    query.append(WHERE_GREATER_THAN);
6650                                            }
6651                                            else {
6652                                                    query.append(WHERE_LESSER_THAN);
6653                                            }
6654                                    }
6655                            }
6656    
6657                            query.append(ORDER_BY_CLAUSE);
6658    
6659                            String[] orderByFields = orderByComparator.getOrderByFields();
6660    
6661                            for (int i = 0; i < orderByFields.length; i++) {
6662                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6663                                    query.append(orderByFields[i]);
6664    
6665                                    if ((i + 1) < orderByFields.length) {
6666                                            if (orderByComparator.isAscending() ^ previous) {
6667                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6668                                            }
6669                                            else {
6670                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6671                                            }
6672                                    }
6673                                    else {
6674                                            if (orderByComparator.isAscending() ^ previous) {
6675                                                    query.append(ORDER_BY_ASC);
6676                                            }
6677                                            else {
6678                                                    query.append(ORDER_BY_DESC);
6679                                            }
6680                                    }
6681                            }
6682                    }
6683                    else {
6684                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6685                    }
6686    
6687                    String sql = query.toString();
6688    
6689                    Query q = session.createQuery(sql);
6690    
6691                    q.setFirstResult(0);
6692                    q.setMaxResults(2);
6693    
6694                    QueryPos qPos = QueryPos.getInstance(q);
6695    
6696                    qPos.add(groupId);
6697    
6698                    qPos.add(userId);
6699    
6700                    if (orderByComparator != null) {
6701                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6702    
6703                            for (Object value : values) {
6704                                    qPos.add(value);
6705                            }
6706                    }
6707    
6708                    List<JournalArticle> list = q.list();
6709    
6710                    if (list.size() == 2) {
6711                            return list.get(1);
6712                    }
6713                    else {
6714                            return null;
6715                    }
6716            }
6717    
6718            /**
6719             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6720             *
6721             * @param groupId the group ID
6722             * @param userId the user ID
6723             * @return the matching journal articles that the user has permission to view
6724             * @throws SystemException if a system exception occurred
6725             */
6726            @Override
6727            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
6728                    throws SystemException {
6729                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
6730                            QueryUtil.ALL_POS, null);
6731            }
6732    
6733            /**
6734             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6735             *
6736             * <p>
6737             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6738             * </p>
6739             *
6740             * @param groupId the group ID
6741             * @param userId the user ID
6742             * @param start the lower bound of the range of journal articles
6743             * @param end the upper bound of the range of journal articles (not inclusive)
6744             * @return the range of matching journal articles that the user has permission to view
6745             * @throws SystemException if a system exception occurred
6746             */
6747            @Override
6748            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6749                    int start, int end) throws SystemException {
6750                    return filterFindByG_U(groupId, userId, start, end, null);
6751            }
6752    
6753            /**
6754             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
6755             *
6756             * <p>
6757             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6758             * </p>
6759             *
6760             * @param groupId the group ID
6761             * @param userId the user ID
6762             * @param start the lower bound of the range of journal articles
6763             * @param end the upper bound of the range of journal articles (not inclusive)
6764             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6765             * @return the ordered range of matching journal articles that the user has permission to view
6766             * @throws SystemException if a system exception occurred
6767             */
6768            @Override
6769            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6770                    int start, int end, OrderByComparator orderByComparator)
6771                    throws SystemException {
6772                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6773                            return findByG_U(groupId, userId, start, end, orderByComparator);
6774                    }
6775    
6776                    StringBundler query = null;
6777    
6778                    if (orderByComparator != null) {
6779                            query = new StringBundler(4 +
6780                                            (orderByComparator.getOrderByFields().length * 3));
6781                    }
6782                    else {
6783                            query = new StringBundler(4);
6784                    }
6785    
6786                    if (getDB().isSupportsInlineDistinct()) {
6787                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6788                    }
6789                    else {
6790                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6791                    }
6792    
6793                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6794    
6795                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6796    
6797                    if (!getDB().isSupportsInlineDistinct()) {
6798                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6799                    }
6800    
6801                    if (orderByComparator != null) {
6802                            if (getDB().isSupportsInlineDistinct()) {
6803                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6804                                            orderByComparator, true);
6805                            }
6806                            else {
6807                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6808                                            orderByComparator, true);
6809                            }
6810                    }
6811                    else {
6812                            if (getDB().isSupportsInlineDistinct()) {
6813                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6814                            }
6815                            else {
6816                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6817                            }
6818                    }
6819    
6820                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6821                                    JournalArticle.class.getName(),
6822                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6823    
6824                    Session session = null;
6825    
6826                    try {
6827                            session = openSession();
6828    
6829                            SQLQuery q = session.createSQLQuery(sql);
6830    
6831                            if (getDB().isSupportsInlineDistinct()) {
6832                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6833                            }
6834                            else {
6835                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6836                            }
6837    
6838                            QueryPos qPos = QueryPos.getInstance(q);
6839    
6840                            qPos.add(groupId);
6841    
6842                            qPos.add(userId);
6843    
6844                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6845                                    end);
6846                    }
6847                    catch (Exception e) {
6848                            throw processException(e);
6849                    }
6850                    finally {
6851                            closeSession(session);
6852                    }
6853            }
6854    
6855            /**
6856             * 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;.
6857             *
6858             * @param id the primary key of the current journal article
6859             * @param groupId the group ID
6860             * @param userId the user ID
6861             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6862             * @return the previous, current, and next journal article
6863             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6864             * @throws SystemException if a system exception occurred
6865             */
6866            @Override
6867            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
6868                    long userId, OrderByComparator orderByComparator)
6869                    throws NoSuchArticleException, SystemException {
6870                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6871                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
6872                    }
6873    
6874                    JournalArticle journalArticle = findByPrimaryKey(id);
6875    
6876                    Session session = null;
6877    
6878                    try {
6879                            session = openSession();
6880    
6881                            JournalArticle[] array = new JournalArticleImpl[3];
6882    
6883                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
6884                                            groupId, userId, orderByComparator, true);
6885    
6886                            array[1] = journalArticle;
6887    
6888                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
6889                                            groupId, userId, orderByComparator, false);
6890    
6891                            return array;
6892                    }
6893                    catch (Exception e) {
6894                            throw processException(e);
6895                    }
6896                    finally {
6897                            closeSession(session);
6898                    }
6899            }
6900    
6901            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
6902                    JournalArticle journalArticle, long groupId, long userId,
6903                    OrderByComparator orderByComparator, boolean previous) {
6904                    StringBundler query = null;
6905    
6906                    if (orderByComparator != null) {
6907                            query = new StringBundler(6 +
6908                                            (orderByComparator.getOrderByFields().length * 6));
6909                    }
6910                    else {
6911                            query = new StringBundler(3);
6912                    }
6913    
6914                    if (getDB().isSupportsInlineDistinct()) {
6915                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6916                    }
6917                    else {
6918                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6919                    }
6920    
6921                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6922    
6923                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6924    
6925                    if (!getDB().isSupportsInlineDistinct()) {
6926                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6927                    }
6928    
6929                    if (orderByComparator != null) {
6930                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6931    
6932                            if (orderByConditionFields.length > 0) {
6933                                    query.append(WHERE_AND);
6934                            }
6935    
6936                            for (int i = 0; i < orderByConditionFields.length; i++) {
6937                                    if (getDB().isSupportsInlineDistinct()) {
6938                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6939                                    }
6940                                    else {
6941                                            query.append(_ORDER_BY_ENTITY_TABLE);
6942                                    }
6943    
6944                                    query.append(orderByConditionFields[i]);
6945    
6946                                    if ((i + 1) < orderByConditionFields.length) {
6947                                            if (orderByComparator.isAscending() ^ previous) {
6948                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6949                                            }
6950                                            else {
6951                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6952                                            }
6953                                    }
6954                                    else {
6955                                            if (orderByComparator.isAscending() ^ previous) {
6956                                                    query.append(WHERE_GREATER_THAN);
6957                                            }
6958                                            else {
6959                                                    query.append(WHERE_LESSER_THAN);
6960                                            }
6961                                    }
6962                            }
6963    
6964                            query.append(ORDER_BY_CLAUSE);
6965    
6966                            String[] orderByFields = orderByComparator.getOrderByFields();
6967    
6968                            for (int i = 0; i < orderByFields.length; i++) {
6969                                    if (getDB().isSupportsInlineDistinct()) {
6970                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6971                                    }
6972                                    else {
6973                                            query.append(_ORDER_BY_ENTITY_TABLE);
6974                                    }
6975    
6976                                    query.append(orderByFields[i]);
6977    
6978                                    if ((i + 1) < orderByFields.length) {
6979                                            if (orderByComparator.isAscending() ^ previous) {
6980                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6981                                            }
6982                                            else {
6983                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6984                                            }
6985                                    }
6986                                    else {
6987                                            if (orderByComparator.isAscending() ^ previous) {
6988                                                    query.append(ORDER_BY_ASC);
6989                                            }
6990                                            else {
6991                                                    query.append(ORDER_BY_DESC);
6992                                            }
6993                                    }
6994                            }
6995                    }
6996                    else {
6997                            if (getDB().isSupportsInlineDistinct()) {
6998                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6999                            }
7000                            else {
7001                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7002                            }
7003                    }
7004    
7005                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7006                                    JournalArticle.class.getName(),
7007                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7008    
7009                    SQLQuery q = session.createSQLQuery(sql);
7010    
7011                    q.setFirstResult(0);
7012                    q.setMaxResults(2);
7013    
7014                    if (getDB().isSupportsInlineDistinct()) {
7015                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7016                    }
7017                    else {
7018                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7019                    }
7020    
7021                    QueryPos qPos = QueryPos.getInstance(q);
7022    
7023                    qPos.add(groupId);
7024    
7025                    qPos.add(userId);
7026    
7027                    if (orderByComparator != null) {
7028                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7029    
7030                            for (Object value : values) {
7031                                    qPos.add(value);
7032                            }
7033                    }
7034    
7035                    List<JournalArticle> list = q.list();
7036    
7037                    if (list.size() == 2) {
7038                            return list.get(1);
7039                    }
7040                    else {
7041                            return null;
7042                    }
7043            }
7044    
7045            /**
7046             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
7047             *
7048             * @param groupId the group ID
7049             * @param userId the user ID
7050             * @throws SystemException if a system exception occurred
7051             */
7052            @Override
7053            public void removeByG_U(long groupId, long userId)
7054                    throws SystemException {
7055                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
7056                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7057                            remove(journalArticle);
7058                    }
7059            }
7060    
7061            /**
7062             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
7063             *
7064             * @param groupId the group ID
7065             * @param userId the user ID
7066             * @return the number of matching journal articles
7067             * @throws SystemException if a system exception occurred
7068             */
7069            @Override
7070            public int countByG_U(long groupId, long userId) throws SystemException {
7071                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
7072    
7073                    Object[] finderArgs = new Object[] { groupId, userId };
7074    
7075                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7076                                    this);
7077    
7078                    if (count == null) {
7079                            StringBundler query = new StringBundler(3);
7080    
7081                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7082    
7083                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7084    
7085                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7086    
7087                            String sql = query.toString();
7088    
7089                            Session session = null;
7090    
7091                            try {
7092                                    session = openSession();
7093    
7094                                    Query q = session.createQuery(sql);
7095    
7096                                    QueryPos qPos = QueryPos.getInstance(q);
7097    
7098                                    qPos.add(groupId);
7099    
7100                                    qPos.add(userId);
7101    
7102                                    count = (Long)q.uniqueResult();
7103    
7104                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7105                            }
7106                            catch (Exception e) {
7107                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7108    
7109                                    throw processException(e);
7110                            }
7111                            finally {
7112                                    closeSession(session);
7113                            }
7114                    }
7115    
7116                    return count.intValue();
7117            }
7118    
7119            /**
7120             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7121             *
7122             * @param groupId the group ID
7123             * @param userId the user ID
7124             * @return the number of matching journal articles that the user has permission to view
7125             * @throws SystemException if a system exception occurred
7126             */
7127            @Override
7128            public int filterCountByG_U(long groupId, long userId)
7129                    throws SystemException {
7130                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7131                            return countByG_U(groupId, userId);
7132                    }
7133    
7134                    StringBundler query = new StringBundler(3);
7135    
7136                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7137    
7138                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7139    
7140                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7141    
7142                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7143                                    JournalArticle.class.getName(),
7144                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7145    
7146                    Session session = null;
7147    
7148                    try {
7149                            session = openSession();
7150    
7151                            SQLQuery q = session.createSQLQuery(sql);
7152    
7153                            q.addScalar(COUNT_COLUMN_NAME,
7154                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7155    
7156                            QueryPos qPos = QueryPos.getInstance(q);
7157    
7158                            qPos.add(groupId);
7159    
7160                            qPos.add(userId);
7161    
7162                            Long count = (Long)q.uniqueResult();
7163    
7164                            return count.intValue();
7165                    }
7166                    catch (Exception e) {
7167                            throw processException(e);
7168                    }
7169                    finally {
7170                            closeSession(session);
7171                    }
7172            }
7173    
7174            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
7175            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
7176            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7177                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7178                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7179                            "findByG_F",
7180                            new String[] {
7181                                    Long.class.getName(), Long.class.getName(),
7182                                    
7183                            Integer.class.getName(), Integer.class.getName(),
7184                                    OrderByComparator.class.getName()
7185                            });
7186            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7187                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7188                            JournalArticleImpl.class,
7189                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
7190                            new String[] { Long.class.getName(), Long.class.getName() },
7191                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7192                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
7193                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7194                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7195            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7196                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7197                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
7198                            new String[] { Long.class.getName(), Long.class.getName() });
7199            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7200                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7201                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
7202                            new String[] { Long.class.getName(), Long.class.getName() });
7203    
7204            /**
7205             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
7206             *
7207             * @param groupId the group ID
7208             * @param folderId the folder ID
7209             * @return the matching journal articles
7210             * @throws SystemException if a system exception occurred
7211             */
7212            @Override
7213            public List<JournalArticle> findByG_F(long groupId, long folderId)
7214                    throws SystemException {
7215                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
7216                            QueryUtil.ALL_POS, null);
7217            }
7218    
7219            /**
7220             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
7221             *
7222             * <p>
7223             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7224             * </p>
7225             *
7226             * @param groupId the group ID
7227             * @param folderId the folder ID
7228             * @param start the lower bound of the range of journal articles
7229             * @param end the upper bound of the range of journal articles (not inclusive)
7230             * @return the range of matching journal articles
7231             * @throws SystemException if a system exception occurred
7232             */
7233            @Override
7234            public List<JournalArticle> findByG_F(long groupId, long folderId,
7235                    int start, int end) throws SystemException {
7236                    return findByG_F(groupId, folderId, start, end, null);
7237            }
7238    
7239            /**
7240             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
7241             *
7242             * <p>
7243             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7244             * </p>
7245             *
7246             * @param groupId the group ID
7247             * @param folderId the folder ID
7248             * @param start the lower bound of the range of journal articles
7249             * @param end the upper bound of the range of journal articles (not inclusive)
7250             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7251             * @return the ordered range of matching journal articles
7252             * @throws SystemException if a system exception occurred
7253             */
7254            @Override
7255            public List<JournalArticle> findByG_F(long groupId, long folderId,
7256                    int start, int end, OrderByComparator orderByComparator)
7257                    throws SystemException {
7258                    boolean pagination = true;
7259                    FinderPath finderPath = null;
7260                    Object[] finderArgs = null;
7261    
7262                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7263                                    (orderByComparator == null)) {
7264                            pagination = false;
7265                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
7266                            finderArgs = new Object[] { groupId, folderId };
7267                    }
7268                    else {
7269                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
7270                            finderArgs = new Object[] {
7271                                            groupId, folderId,
7272                                            
7273                                            start, end, orderByComparator
7274                                    };
7275                    }
7276    
7277                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7278                                    finderArgs, this);
7279    
7280                    if ((list != null) && !list.isEmpty()) {
7281                            for (JournalArticle journalArticle : list) {
7282                                    if ((groupId != journalArticle.getGroupId()) ||
7283                                                    (folderId != journalArticle.getFolderId())) {
7284                                            list = null;
7285    
7286                                            break;
7287                                    }
7288                            }
7289                    }
7290    
7291                    if (list == null) {
7292                            StringBundler query = null;
7293    
7294                            if (orderByComparator != null) {
7295                                    query = new StringBundler(4 +
7296                                                    (orderByComparator.getOrderByFields().length * 3));
7297                            }
7298                            else {
7299                                    query = new StringBundler(4);
7300                            }
7301    
7302                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7303    
7304                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7305    
7306                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7307    
7308                            if (orderByComparator != null) {
7309                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7310                                            orderByComparator);
7311                            }
7312                            else
7313                             if (pagination) {
7314                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7315                            }
7316    
7317                            String sql = query.toString();
7318    
7319                            Session session = null;
7320    
7321                            try {
7322                                    session = openSession();
7323    
7324                                    Query q = session.createQuery(sql);
7325    
7326                                    QueryPos qPos = QueryPos.getInstance(q);
7327    
7328                                    qPos.add(groupId);
7329    
7330                                    qPos.add(folderId);
7331    
7332                                    if (!pagination) {
7333                                            list = (List<JournalArticle>)QueryUtil.list(q,
7334                                                            getDialect(), start, end, false);
7335    
7336                                            Collections.sort(list);
7337    
7338                                            list = new UnmodifiableList<JournalArticle>(list);
7339                                    }
7340                                    else {
7341                                            list = (List<JournalArticle>)QueryUtil.list(q,
7342                                                            getDialect(), start, end);
7343                                    }
7344    
7345                                    cacheResult(list);
7346    
7347                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7348                            }
7349                            catch (Exception e) {
7350                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7351    
7352                                    throw processException(e);
7353                            }
7354                            finally {
7355                                    closeSession(session);
7356                            }
7357                    }
7358    
7359                    return list;
7360            }
7361    
7362            /**
7363             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7364             *
7365             * @param groupId the group ID
7366             * @param folderId the folder ID
7367             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7368             * @return the first matching journal article
7369             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7370             * @throws SystemException if a system exception occurred
7371             */
7372            @Override
7373            public JournalArticle findByG_F_First(long groupId, long folderId,
7374                    OrderByComparator orderByComparator)
7375                    throws NoSuchArticleException, SystemException {
7376                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
7377                                    orderByComparator);
7378    
7379                    if (journalArticle != null) {
7380                            return journalArticle;
7381                    }
7382    
7383                    StringBundler msg = new StringBundler(6);
7384    
7385                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7386    
7387                    msg.append("groupId=");
7388                    msg.append(groupId);
7389    
7390                    msg.append(", folderId=");
7391                    msg.append(folderId);
7392    
7393                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7394    
7395                    throw new NoSuchArticleException(msg.toString());
7396            }
7397    
7398            /**
7399             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7400             *
7401             * @param groupId the group ID
7402             * @param folderId the folder ID
7403             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7404             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7405             * @throws SystemException if a system exception occurred
7406             */
7407            @Override
7408            public JournalArticle fetchByG_F_First(long groupId, long folderId,
7409                    OrderByComparator orderByComparator) throws SystemException {
7410                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
7411                                    orderByComparator);
7412    
7413                    if (!list.isEmpty()) {
7414                            return list.get(0);
7415                    }
7416    
7417                    return null;
7418            }
7419    
7420            /**
7421             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7422             *
7423             * @param groupId the group ID
7424             * @param folderId the folder ID
7425             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7426             * @return the last matching journal article
7427             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7428             * @throws SystemException if a system exception occurred
7429             */
7430            @Override
7431            public JournalArticle findByG_F_Last(long groupId, long folderId,
7432                    OrderByComparator orderByComparator)
7433                    throws NoSuchArticleException, SystemException {
7434                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
7435                                    orderByComparator);
7436    
7437                    if (journalArticle != null) {
7438                            return journalArticle;
7439                    }
7440    
7441                    StringBundler msg = new StringBundler(6);
7442    
7443                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7444    
7445                    msg.append("groupId=");
7446                    msg.append(groupId);
7447    
7448                    msg.append(", folderId=");
7449                    msg.append(folderId);
7450    
7451                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7452    
7453                    throw new NoSuchArticleException(msg.toString());
7454            }
7455    
7456            /**
7457             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7458             *
7459             * @param groupId the group ID
7460             * @param folderId the folder ID
7461             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7462             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7463             * @throws SystemException if a system exception occurred
7464             */
7465            @Override
7466            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
7467                    OrderByComparator orderByComparator) throws SystemException {
7468                    int count = countByG_F(groupId, folderId);
7469    
7470                    if (count == 0) {
7471                            return null;
7472                    }
7473    
7474                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
7475                                    count, orderByComparator);
7476    
7477                    if (!list.isEmpty()) {
7478                            return list.get(0);
7479                    }
7480    
7481                    return null;
7482            }
7483    
7484            /**
7485             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7486             *
7487             * @param id the primary key of the current journal article
7488             * @param groupId the group ID
7489             * @param folderId the folder ID
7490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7491             * @return the previous, current, and next journal article
7492             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7493             * @throws SystemException if a system exception occurred
7494             */
7495            @Override
7496            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
7497                    long folderId, OrderByComparator orderByComparator)
7498                    throws NoSuchArticleException, SystemException {
7499                    JournalArticle journalArticle = findByPrimaryKey(id);
7500    
7501                    Session session = null;
7502    
7503                    try {
7504                            session = openSession();
7505    
7506                            JournalArticle[] array = new JournalArticleImpl[3];
7507    
7508                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7509                                            folderId, orderByComparator, true);
7510    
7511                            array[1] = journalArticle;
7512    
7513                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7514                                            folderId, orderByComparator, false);
7515    
7516                            return array;
7517                    }
7518                    catch (Exception e) {
7519                            throw processException(e);
7520                    }
7521                    finally {
7522                            closeSession(session);
7523                    }
7524            }
7525    
7526            protected JournalArticle getByG_F_PrevAndNext(Session session,
7527                    JournalArticle journalArticle, long groupId, long folderId,
7528                    OrderByComparator orderByComparator, boolean previous) {
7529                    StringBundler query = null;
7530    
7531                    if (orderByComparator != null) {
7532                            query = new StringBundler(6 +
7533                                            (orderByComparator.getOrderByFields().length * 6));
7534                    }
7535                    else {
7536                            query = new StringBundler(3);
7537                    }
7538    
7539                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7540    
7541                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7542    
7543                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7544    
7545                    if (orderByComparator != null) {
7546                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7547    
7548                            if (orderByConditionFields.length > 0) {
7549                                    query.append(WHERE_AND);
7550                            }
7551    
7552                            for (int i = 0; i < orderByConditionFields.length; i++) {
7553                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7554                                    query.append(orderByConditionFields[i]);
7555    
7556                                    if ((i + 1) < orderByConditionFields.length) {
7557                                            if (orderByComparator.isAscending() ^ previous) {
7558                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7559                                            }
7560                                            else {
7561                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7562                                            }
7563                                    }
7564                                    else {
7565                                            if (orderByComparator.isAscending() ^ previous) {
7566                                                    query.append(WHERE_GREATER_THAN);
7567                                            }
7568                                            else {
7569                                                    query.append(WHERE_LESSER_THAN);
7570                                            }
7571                                    }
7572                            }
7573    
7574                            query.append(ORDER_BY_CLAUSE);
7575    
7576                            String[] orderByFields = orderByComparator.getOrderByFields();
7577    
7578                            for (int i = 0; i < orderByFields.length; i++) {
7579                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7580                                    query.append(orderByFields[i]);
7581    
7582                                    if ((i + 1) < orderByFields.length) {
7583                                            if (orderByComparator.isAscending() ^ previous) {
7584                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7585                                            }
7586                                            else {
7587                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7588                                            }
7589                                    }
7590                                    else {
7591                                            if (orderByComparator.isAscending() ^ previous) {
7592                                                    query.append(ORDER_BY_ASC);
7593                                            }
7594                                            else {
7595                                                    query.append(ORDER_BY_DESC);
7596                                            }
7597                                    }
7598                            }
7599                    }
7600                    else {
7601                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7602                    }
7603    
7604                    String sql = query.toString();
7605    
7606                    Query q = session.createQuery(sql);
7607    
7608                    q.setFirstResult(0);
7609                    q.setMaxResults(2);
7610    
7611                    QueryPos qPos = QueryPos.getInstance(q);
7612    
7613                    qPos.add(groupId);
7614    
7615                    qPos.add(folderId);
7616    
7617                    if (orderByComparator != null) {
7618                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7619    
7620                            for (Object value : values) {
7621                                    qPos.add(value);
7622                            }
7623                    }
7624    
7625                    List<JournalArticle> list = q.list();
7626    
7627                    if (list.size() == 2) {
7628                            return list.get(1);
7629                    }
7630                    else {
7631                            return null;
7632                    }
7633            }
7634    
7635            /**
7636             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7637             *
7638             * @param groupId the group ID
7639             * @param folderId the folder ID
7640             * @return the matching journal articles that the user has permission to view
7641             * @throws SystemException if a system exception occurred
7642             */
7643            @Override
7644            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
7645                    throws SystemException {
7646                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
7647                            QueryUtil.ALL_POS, null);
7648            }
7649    
7650            /**
7651             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7652             *
7653             * <p>
7654             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7655             * </p>
7656             *
7657             * @param groupId the group ID
7658             * @param folderId the folder ID
7659             * @param start the lower bound of the range of journal articles
7660             * @param end the upper bound of the range of journal articles (not inclusive)
7661             * @return the range of matching journal articles that the user has permission to view
7662             * @throws SystemException if a system exception occurred
7663             */
7664            @Override
7665            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7666                    int start, int end) throws SystemException {
7667                    return filterFindByG_F(groupId, folderId, start, end, null);
7668            }
7669    
7670            /**
7671             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
7672             *
7673             * <p>
7674             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7675             * </p>
7676             *
7677             * @param groupId the group ID
7678             * @param folderId the folder ID
7679             * @param start the lower bound of the range of journal articles
7680             * @param end the upper bound of the range of journal articles (not inclusive)
7681             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7682             * @return the ordered range of matching journal articles that the user has permission to view
7683             * @throws SystemException if a system exception occurred
7684             */
7685            @Override
7686            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7687                    int start, int end, OrderByComparator orderByComparator)
7688                    throws SystemException {
7689                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7690                            return findByG_F(groupId, folderId, start, end, orderByComparator);
7691                    }
7692    
7693                    StringBundler query = null;
7694    
7695                    if (orderByComparator != null) {
7696                            query = new StringBundler(4 +
7697                                            (orderByComparator.getOrderByFields().length * 3));
7698                    }
7699                    else {
7700                            query = new StringBundler(4);
7701                    }
7702    
7703                    if (getDB().isSupportsInlineDistinct()) {
7704                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7705                    }
7706                    else {
7707                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7708                    }
7709    
7710                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7711    
7712                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7713    
7714                    if (!getDB().isSupportsInlineDistinct()) {
7715                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7716                    }
7717    
7718                    if (orderByComparator != null) {
7719                            if (getDB().isSupportsInlineDistinct()) {
7720                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7721                                            orderByComparator, true);
7722                            }
7723                            else {
7724                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7725                                            orderByComparator, true);
7726                            }
7727                    }
7728                    else {
7729                            if (getDB().isSupportsInlineDistinct()) {
7730                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7731                            }
7732                            else {
7733                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7734                            }
7735                    }
7736    
7737                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7738                                    JournalArticle.class.getName(),
7739                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7740    
7741                    Session session = null;
7742    
7743                    try {
7744                            session = openSession();
7745    
7746                            SQLQuery q = session.createSQLQuery(sql);
7747    
7748                            if (getDB().isSupportsInlineDistinct()) {
7749                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7750                            }
7751                            else {
7752                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7753                            }
7754    
7755                            QueryPos qPos = QueryPos.getInstance(q);
7756    
7757                            qPos.add(groupId);
7758    
7759                            qPos.add(folderId);
7760    
7761                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7762                                    end);
7763                    }
7764                    catch (Exception e) {
7765                            throw processException(e);
7766                    }
7767                    finally {
7768                            closeSession(session);
7769                    }
7770            }
7771    
7772            /**
7773             * 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;.
7774             *
7775             * @param id the primary key of the current journal article
7776             * @param groupId the group ID
7777             * @param folderId the folder ID
7778             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7779             * @return the previous, current, and next journal article
7780             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7781             * @throws SystemException if a system exception occurred
7782             */
7783            @Override
7784            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
7785                    long folderId, OrderByComparator orderByComparator)
7786                    throws NoSuchArticleException, SystemException {
7787                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7788                            return findByG_F_PrevAndNext(id, groupId, folderId,
7789                                    orderByComparator);
7790                    }
7791    
7792                    JournalArticle journalArticle = findByPrimaryKey(id);
7793    
7794                    Session session = null;
7795    
7796                    try {
7797                            session = openSession();
7798    
7799                            JournalArticle[] array = new JournalArticleImpl[3];
7800    
7801                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
7802                                            groupId, folderId, orderByComparator, true);
7803    
7804                            array[1] = journalArticle;
7805    
7806                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
7807                                            groupId, folderId, orderByComparator, false);
7808    
7809                            return array;
7810                    }
7811                    catch (Exception e) {
7812                            throw processException(e);
7813                    }
7814                    finally {
7815                            closeSession(session);
7816                    }
7817            }
7818    
7819            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
7820                    JournalArticle journalArticle, long groupId, long folderId,
7821                    OrderByComparator orderByComparator, boolean previous) {
7822                    StringBundler query = null;
7823    
7824                    if (orderByComparator != null) {
7825                            query = new StringBundler(6 +
7826                                            (orderByComparator.getOrderByFields().length * 6));
7827                    }
7828                    else {
7829                            query = new StringBundler(3);
7830                    }
7831    
7832                    if (getDB().isSupportsInlineDistinct()) {
7833                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7834                    }
7835                    else {
7836                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7837                    }
7838    
7839                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7840    
7841                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7842    
7843                    if (!getDB().isSupportsInlineDistinct()) {
7844                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7845                    }
7846    
7847                    if (orderByComparator != null) {
7848                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7849    
7850                            if (orderByConditionFields.length > 0) {
7851                                    query.append(WHERE_AND);
7852                            }
7853    
7854                            for (int i = 0; i < orderByConditionFields.length; i++) {
7855                                    if (getDB().isSupportsInlineDistinct()) {
7856                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7857                                    }
7858                                    else {
7859                                            query.append(_ORDER_BY_ENTITY_TABLE);
7860                                    }
7861    
7862                                    query.append(orderByConditionFields[i]);
7863    
7864                                    if ((i + 1) < orderByConditionFields.length) {
7865                                            if (orderByComparator.isAscending() ^ previous) {
7866                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7867                                            }
7868                                            else {
7869                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7870                                            }
7871                                    }
7872                                    else {
7873                                            if (orderByComparator.isAscending() ^ previous) {
7874                                                    query.append(WHERE_GREATER_THAN);
7875                                            }
7876                                            else {
7877                                                    query.append(WHERE_LESSER_THAN);
7878                                            }
7879                                    }
7880                            }
7881    
7882                            query.append(ORDER_BY_CLAUSE);
7883    
7884                            String[] orderByFields = orderByComparator.getOrderByFields();
7885    
7886                            for (int i = 0; i < orderByFields.length; i++) {
7887                                    if (getDB().isSupportsInlineDistinct()) {
7888                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7889                                    }
7890                                    else {
7891                                            query.append(_ORDER_BY_ENTITY_TABLE);
7892                                    }
7893    
7894                                    query.append(orderByFields[i]);
7895    
7896                                    if ((i + 1) < orderByFields.length) {
7897                                            if (orderByComparator.isAscending() ^ previous) {
7898                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7899                                            }
7900                                            else {
7901                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7902                                            }
7903                                    }
7904                                    else {
7905                                            if (orderByComparator.isAscending() ^ previous) {
7906                                                    query.append(ORDER_BY_ASC);
7907                                            }
7908                                            else {
7909                                                    query.append(ORDER_BY_DESC);
7910                                            }
7911                                    }
7912                            }
7913                    }
7914                    else {
7915                            if (getDB().isSupportsInlineDistinct()) {
7916                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7917                            }
7918                            else {
7919                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7920                            }
7921                    }
7922    
7923                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7924                                    JournalArticle.class.getName(),
7925                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7926    
7927                    SQLQuery q = session.createSQLQuery(sql);
7928    
7929                    q.setFirstResult(0);
7930                    q.setMaxResults(2);
7931    
7932                    if (getDB().isSupportsInlineDistinct()) {
7933                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7934                    }
7935                    else {
7936                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7937                    }
7938    
7939                    QueryPos qPos = QueryPos.getInstance(q);
7940    
7941                    qPos.add(groupId);
7942    
7943                    qPos.add(folderId);
7944    
7945                    if (orderByComparator != null) {
7946                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7947    
7948                            for (Object value : values) {
7949                                    qPos.add(value);
7950                            }
7951                    }
7952    
7953                    List<JournalArticle> list = q.list();
7954    
7955                    if (list.size() == 2) {
7956                            return list.get(1);
7957                    }
7958                    else {
7959                            return null;
7960                    }
7961            }
7962    
7963            /**
7964             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7965             *
7966             * @param groupId the group ID
7967             * @param folderIds the folder IDs
7968             * @return the matching journal articles that the user has permission to view
7969             * @throws SystemException if a system exception occurred
7970             */
7971            @Override
7972            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
7973                    throws SystemException {
7974                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7975                            QueryUtil.ALL_POS, null);
7976            }
7977    
7978            /**
7979             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7980             *
7981             * <p>
7982             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7983             * </p>
7984             *
7985             * @param groupId the group ID
7986             * @param folderIds the folder IDs
7987             * @param start the lower bound of the range of journal articles
7988             * @param end the upper bound of the range of journal articles (not inclusive)
7989             * @return the range of matching journal articles that the user has permission to view
7990             * @throws SystemException if a system exception occurred
7991             */
7992            @Override
7993            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
7994                    int start, int end) throws SystemException {
7995                    return filterFindByG_F(groupId, folderIds, start, end, null);
7996            }
7997    
7998            /**
7999             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8000             *
8001             * <p>
8002             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8003             * </p>
8004             *
8005             * @param groupId the group ID
8006             * @param folderIds the folder IDs
8007             * @param start the lower bound of the range of journal articles
8008             * @param end the upper bound of the range of journal articles (not inclusive)
8009             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8010             * @return the ordered range of matching journal articles that the user has permission to view
8011             * @throws SystemException if a system exception occurred
8012             */
8013            @Override
8014            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8015                    int start, int end, OrderByComparator orderByComparator)
8016                    throws SystemException {
8017                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8018                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8019                    }
8020    
8021                    StringBundler query = new StringBundler();
8022    
8023                    if (getDB().isSupportsInlineDistinct()) {
8024                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8025                    }
8026                    else {
8027                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8028                    }
8029    
8030                    boolean conjunctionable = false;
8031    
8032                    if (conjunctionable) {
8033                            query.append(WHERE_AND);
8034                    }
8035    
8036                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8037    
8038                    conjunctionable = true;
8039    
8040                    if ((folderIds == null) || (folderIds.length > 0)) {
8041                            if (conjunctionable) {
8042                                    query.append(WHERE_AND);
8043                            }
8044    
8045                            query.append(StringPool.OPEN_PARENTHESIS);
8046    
8047                            for (int i = 0; i < folderIds.length; i++) {
8048                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8049    
8050                                    if ((i + 1) < folderIds.length) {
8051                                            query.append(WHERE_OR);
8052                                    }
8053                            }
8054    
8055                            query.append(StringPool.CLOSE_PARENTHESIS);
8056    
8057                            conjunctionable = true;
8058                    }
8059    
8060                    if (!getDB().isSupportsInlineDistinct()) {
8061                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8062                    }
8063    
8064                    if (orderByComparator != null) {
8065                            if (getDB().isSupportsInlineDistinct()) {
8066                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8067                                            orderByComparator, true);
8068                            }
8069                            else {
8070                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8071                                            orderByComparator, true);
8072                            }
8073                    }
8074                    else {
8075                            if (getDB().isSupportsInlineDistinct()) {
8076                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8077                            }
8078                            else {
8079                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8080                            }
8081                    }
8082    
8083                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8084                                    JournalArticle.class.getName(),
8085                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8086    
8087                    Session session = null;
8088    
8089                    try {
8090                            session = openSession();
8091    
8092                            SQLQuery q = session.createSQLQuery(sql);
8093    
8094                            if (getDB().isSupportsInlineDistinct()) {
8095                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8096                            }
8097                            else {
8098                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8099                            }
8100    
8101                            QueryPos qPos = QueryPos.getInstance(q);
8102    
8103                            qPos.add(groupId);
8104    
8105                            if (folderIds != null) {
8106                                    qPos.add(folderIds);
8107                            }
8108    
8109                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8110                                    end);
8111                    }
8112                    catch (Exception e) {
8113                            throw processException(e);
8114                    }
8115                    finally {
8116                            closeSession(session);
8117                    }
8118            }
8119    
8120            /**
8121             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
8122             *
8123             * <p>
8124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8125             * </p>
8126             *
8127             * @param groupId the group ID
8128             * @param folderIds the folder IDs
8129             * @return the matching journal articles
8130             * @throws SystemException if a system exception occurred
8131             */
8132            @Override
8133            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
8134                    throws SystemException {
8135                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8136                            QueryUtil.ALL_POS, null);
8137            }
8138    
8139            /**
8140             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8141             *
8142             * <p>
8143             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8144             * </p>
8145             *
8146             * @param groupId the group ID
8147             * @param folderIds the folder IDs
8148             * @param start the lower bound of the range of journal articles
8149             * @param end the upper bound of the range of journal articles (not inclusive)
8150             * @return the range of matching journal articles
8151             * @throws SystemException if a system exception occurred
8152             */
8153            @Override
8154            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8155                    int start, int end) throws SystemException {
8156                    return findByG_F(groupId, folderIds, start, end, null);
8157            }
8158    
8159            /**
8160             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8161             *
8162             * <p>
8163             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8164             * </p>
8165             *
8166             * @param groupId the group ID
8167             * @param folderIds the folder IDs
8168             * @param start the lower bound of the range of journal articles
8169             * @param end the upper bound of the range of journal articles (not inclusive)
8170             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8171             * @return the ordered range of matching journal articles
8172             * @throws SystemException if a system exception occurred
8173             */
8174            @Override
8175            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8176                    int start, int end, OrderByComparator orderByComparator)
8177                    throws SystemException {
8178                    if ((folderIds != null) && (folderIds.length == 1)) {
8179                            return findByG_F(groupId, folderIds[0], start, end,
8180                                    orderByComparator);
8181                    }
8182    
8183                    boolean pagination = true;
8184                    Object[] finderArgs = null;
8185    
8186                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8187                                    (orderByComparator == null)) {
8188                            pagination = false;
8189                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8190                    }
8191                    else {
8192                            finderArgs = new Object[] {
8193                                            groupId, StringUtil.merge(folderIds),
8194                                            
8195                                            start, end, orderByComparator
8196                                    };
8197                    }
8198    
8199                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8200                                    finderArgs, this);
8201    
8202                    if ((list != null) && !list.isEmpty()) {
8203                            for (JournalArticle journalArticle : list) {
8204                                    if ((groupId != journalArticle.getGroupId()) ||
8205                                                    !ArrayUtil.contains(folderIds,
8206                                                            journalArticle.getFolderId())) {
8207                                            list = null;
8208    
8209                                            break;
8210                                    }
8211                            }
8212                    }
8213    
8214                    if (list == null) {
8215                            StringBundler query = new StringBundler();
8216    
8217                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8218    
8219                            boolean conjunctionable = false;
8220    
8221                            if (conjunctionable) {
8222                                    query.append(WHERE_AND);
8223                            }
8224    
8225                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8226    
8227                            conjunctionable = true;
8228    
8229                            if ((folderIds == null) || (folderIds.length > 0)) {
8230                                    if (conjunctionable) {
8231                                            query.append(WHERE_AND);
8232                                    }
8233    
8234                                    query.append(StringPool.OPEN_PARENTHESIS);
8235    
8236                                    for (int i = 0; i < folderIds.length; i++) {
8237                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8238    
8239                                            if ((i + 1) < folderIds.length) {
8240                                                    query.append(WHERE_OR);
8241                                            }
8242                                    }
8243    
8244                                    query.append(StringPool.CLOSE_PARENTHESIS);
8245    
8246                                    conjunctionable = true;
8247                            }
8248    
8249                            if (orderByComparator != null) {
8250                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8251                                            orderByComparator);
8252                            }
8253                            else
8254                             if (pagination) {
8255                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8256                            }
8257    
8258                            String sql = query.toString();
8259    
8260                            Session session = null;
8261    
8262                            try {
8263                                    session = openSession();
8264    
8265                                    Query q = session.createQuery(sql);
8266    
8267                                    QueryPos qPos = QueryPos.getInstance(q);
8268    
8269                                    qPos.add(groupId);
8270    
8271                                    if (folderIds != null) {
8272                                            qPos.add(folderIds);
8273                                    }
8274    
8275                                    if (!pagination) {
8276                                            list = (List<JournalArticle>)QueryUtil.list(q,
8277                                                            getDialect(), start, end, false);
8278    
8279                                            Collections.sort(list);
8280    
8281                                            list = new UnmodifiableList<JournalArticle>(list);
8282                                    }
8283                                    else {
8284                                            list = (List<JournalArticle>)QueryUtil.list(q,
8285                                                            getDialect(), start, end);
8286                                    }
8287    
8288                                    cacheResult(list);
8289    
8290                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8291                                            finderArgs, list);
8292                            }
8293                            catch (Exception e) {
8294                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8295                                            finderArgs);
8296    
8297                                    throw processException(e);
8298                            }
8299                            finally {
8300                                    closeSession(session);
8301                            }
8302                    }
8303    
8304                    return list;
8305            }
8306    
8307            /**
8308             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
8309             *
8310             * @param groupId the group ID
8311             * @param folderId the folder ID
8312             * @throws SystemException if a system exception occurred
8313             */
8314            @Override
8315            public void removeByG_F(long groupId, long folderId)
8316                    throws SystemException {
8317                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
8318                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8319                            remove(journalArticle);
8320                    }
8321            }
8322    
8323            /**
8324             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
8325             *
8326             * @param groupId the group ID
8327             * @param folderId the folder ID
8328             * @return the number of matching journal articles
8329             * @throws SystemException if a system exception occurred
8330             */
8331            @Override
8332            public int countByG_F(long groupId, long folderId)
8333                    throws SystemException {
8334                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
8335    
8336                    Object[] finderArgs = new Object[] { groupId, folderId };
8337    
8338                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8339                                    this);
8340    
8341                    if (count == null) {
8342                            StringBundler query = new StringBundler(3);
8343    
8344                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8345    
8346                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8347    
8348                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8349    
8350                            String sql = query.toString();
8351    
8352                            Session session = null;
8353    
8354                            try {
8355                                    session = openSession();
8356    
8357                                    Query q = session.createQuery(sql);
8358    
8359                                    QueryPos qPos = QueryPos.getInstance(q);
8360    
8361                                    qPos.add(groupId);
8362    
8363                                    qPos.add(folderId);
8364    
8365                                    count = (Long)q.uniqueResult();
8366    
8367                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8368                            }
8369                            catch (Exception e) {
8370                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8371    
8372                                    throw processException(e);
8373                            }
8374                            finally {
8375                                    closeSession(session);
8376                            }
8377                    }
8378    
8379                    return count.intValue();
8380            }
8381    
8382            /**
8383             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
8384             *
8385             * @param groupId the group ID
8386             * @param folderIds the folder IDs
8387             * @return the number of matching journal articles
8388             * @throws SystemException if a system exception occurred
8389             */
8390            @Override
8391            public int countByG_F(long groupId, long[] folderIds)
8392                    throws SystemException {
8393                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8394    
8395                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8396                                    finderArgs, this);
8397    
8398                    if (count == null) {
8399                            StringBundler query = new StringBundler();
8400    
8401                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8402    
8403                            boolean conjunctionable = false;
8404    
8405                            if (conjunctionable) {
8406                                    query.append(WHERE_AND);
8407                            }
8408    
8409                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8410    
8411                            conjunctionable = true;
8412    
8413                            if ((folderIds == null) || (folderIds.length > 0)) {
8414                                    if (conjunctionable) {
8415                                            query.append(WHERE_AND);
8416                                    }
8417    
8418                                    query.append(StringPool.OPEN_PARENTHESIS);
8419    
8420                                    for (int i = 0; i < folderIds.length; i++) {
8421                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8422    
8423                                            if ((i + 1) < folderIds.length) {
8424                                                    query.append(WHERE_OR);
8425                                            }
8426                                    }
8427    
8428                                    query.append(StringPool.CLOSE_PARENTHESIS);
8429    
8430                                    conjunctionable = true;
8431                            }
8432    
8433                            String sql = query.toString();
8434    
8435                            Session session = null;
8436    
8437                            try {
8438                                    session = openSession();
8439    
8440                                    Query q = session.createQuery(sql);
8441    
8442                                    QueryPos qPos = QueryPos.getInstance(q);
8443    
8444                                    qPos.add(groupId);
8445    
8446                                    if (folderIds != null) {
8447                                            qPos.add(folderIds);
8448                                    }
8449    
8450                                    count = (Long)q.uniqueResult();
8451    
8452                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8453                                            finderArgs, count);
8454                            }
8455                            catch (Exception e) {
8456                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8457                                            finderArgs);
8458    
8459                                    throw processException(e);
8460                            }
8461                            finally {
8462                                    closeSession(session);
8463                            }
8464                    }
8465    
8466                    return count.intValue();
8467            }
8468    
8469            /**
8470             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8471             *
8472             * @param groupId the group ID
8473             * @param folderId the folder ID
8474             * @return the number of matching journal articles that the user has permission to view
8475             * @throws SystemException if a system exception occurred
8476             */
8477            @Override
8478            public int filterCountByG_F(long groupId, long folderId)
8479                    throws SystemException {
8480                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8481                            return countByG_F(groupId, folderId);
8482                    }
8483    
8484                    StringBundler query = new StringBundler(3);
8485    
8486                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8487    
8488                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8489    
8490                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8491    
8492                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8493                                    JournalArticle.class.getName(),
8494                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8495    
8496                    Session session = null;
8497    
8498                    try {
8499                            session = openSession();
8500    
8501                            SQLQuery q = session.createSQLQuery(sql);
8502    
8503                            q.addScalar(COUNT_COLUMN_NAME,
8504                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8505    
8506                            QueryPos qPos = QueryPos.getInstance(q);
8507    
8508                            qPos.add(groupId);
8509    
8510                            qPos.add(folderId);
8511    
8512                            Long count = (Long)q.uniqueResult();
8513    
8514                            return count.intValue();
8515                    }
8516                    catch (Exception e) {
8517                            throw processException(e);
8518                    }
8519                    finally {
8520                            closeSession(session);
8521                    }
8522            }
8523    
8524            /**
8525             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8526             *
8527             * @param groupId the group ID
8528             * @param folderIds the folder IDs
8529             * @return the number of matching journal articles that the user has permission to view
8530             * @throws SystemException if a system exception occurred
8531             */
8532            @Override
8533            public int filterCountByG_F(long groupId, long[] folderIds)
8534                    throws SystemException {
8535                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8536                            return countByG_F(groupId, folderIds);
8537                    }
8538    
8539                    StringBundler query = new StringBundler();
8540    
8541                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8542    
8543                    boolean conjunctionable = false;
8544    
8545                    if (conjunctionable) {
8546                            query.append(WHERE_AND);
8547                    }
8548    
8549                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8550    
8551                    conjunctionable = true;
8552    
8553                    if ((folderIds == null) || (folderIds.length > 0)) {
8554                            if (conjunctionable) {
8555                                    query.append(WHERE_AND);
8556                            }
8557    
8558                            query.append(StringPool.OPEN_PARENTHESIS);
8559    
8560                            for (int i = 0; i < folderIds.length; i++) {
8561                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8562    
8563                                    if ((i + 1) < folderIds.length) {
8564                                            query.append(WHERE_OR);
8565                                    }
8566                            }
8567    
8568                            query.append(StringPool.CLOSE_PARENTHESIS);
8569    
8570                            conjunctionable = true;
8571                    }
8572    
8573                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8574                                    JournalArticle.class.getName(),
8575                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8576    
8577                    Session session = null;
8578    
8579                    try {
8580                            session = openSession();
8581    
8582                            SQLQuery q = session.createSQLQuery(sql);
8583    
8584                            q.addScalar(COUNT_COLUMN_NAME,
8585                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8586    
8587                            QueryPos qPos = QueryPos.getInstance(q);
8588    
8589                            qPos.add(groupId);
8590    
8591                            if (folderIds != null) {
8592                                    qPos.add(folderIds);
8593                            }
8594    
8595                            Long count = (Long)q.uniqueResult();
8596    
8597                            return count.intValue();
8598                    }
8599                    catch (Exception e) {
8600                            throw processException(e);
8601                    }
8602                    finally {
8603                            closeSession(session);
8604                    }
8605            }
8606    
8607            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
8608            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
8609                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
8610            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
8611            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
8612                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
8613            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8614                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8615                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
8616                            "findByG_A",
8617                            new String[] {
8618                                    Long.class.getName(), String.class.getName(),
8619                                    
8620                            Integer.class.getName(), Integer.class.getName(),
8621                                    OrderByComparator.class.getName()
8622                            });
8623            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8624                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8625                            JournalArticleImpl.class,
8626                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
8627                            new String[] { Long.class.getName(), String.class.getName() },
8628                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
8629                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
8630                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
8631            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8632                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8633                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
8634                            new String[] { Long.class.getName(), String.class.getName() });
8635    
8636            /**
8637             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
8638             *
8639             * @param groupId the group ID
8640             * @param articleId the article ID
8641             * @return the matching journal articles
8642             * @throws SystemException if a system exception occurred
8643             */
8644            @Override
8645            public List<JournalArticle> findByG_A(long groupId, String articleId)
8646                    throws SystemException {
8647                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
8648                            QueryUtil.ALL_POS, null);
8649            }
8650    
8651            /**
8652             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
8653             *
8654             * <p>
8655             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8656             * </p>
8657             *
8658             * @param groupId the group ID
8659             * @param articleId the article ID
8660             * @param start the lower bound of the range of journal articles
8661             * @param end the upper bound of the range of journal articles (not inclusive)
8662             * @return the range of matching journal articles
8663             * @throws SystemException if a system exception occurred
8664             */
8665            @Override
8666            public List<JournalArticle> findByG_A(long groupId, String articleId,
8667                    int start, int end) throws SystemException {
8668                    return findByG_A(groupId, articleId, start, end, null);
8669            }
8670    
8671            /**
8672             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
8673             *
8674             * <p>
8675             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8676             * </p>
8677             *
8678             * @param groupId the group ID
8679             * @param articleId the article ID
8680             * @param start the lower bound of the range of journal articles
8681             * @param end the upper bound of the range of journal articles (not inclusive)
8682             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8683             * @return the ordered range of matching journal articles
8684             * @throws SystemException if a system exception occurred
8685             */
8686            @Override
8687            public List<JournalArticle> findByG_A(long groupId, String articleId,
8688                    int start, int end, OrderByComparator orderByComparator)
8689                    throws SystemException {
8690                    boolean pagination = true;
8691                    FinderPath finderPath = null;
8692                    Object[] finderArgs = null;
8693    
8694                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8695                                    (orderByComparator == null)) {
8696                            pagination = false;
8697                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
8698                            finderArgs = new Object[] { groupId, articleId };
8699                    }
8700                    else {
8701                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
8702                            finderArgs = new Object[] {
8703                                            groupId, articleId,
8704                                            
8705                                            start, end, orderByComparator
8706                                    };
8707                    }
8708    
8709                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8710                                    finderArgs, this);
8711    
8712                    if ((list != null) && !list.isEmpty()) {
8713                            for (JournalArticle journalArticle : list) {
8714                                    if ((groupId != journalArticle.getGroupId()) ||
8715                                                    !Validator.equals(articleId,
8716                                                            journalArticle.getArticleId())) {
8717                                            list = null;
8718    
8719                                            break;
8720                                    }
8721                            }
8722                    }
8723    
8724                    if (list == null) {
8725                            StringBundler query = null;
8726    
8727                            if (orderByComparator != null) {
8728                                    query = new StringBundler(4 +
8729                                                    (orderByComparator.getOrderByFields().length * 3));
8730                            }
8731                            else {
8732                                    query = new StringBundler(4);
8733                            }
8734    
8735                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8736    
8737                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8738    
8739                            boolean bindArticleId = false;
8740    
8741                            if (articleId == null) {
8742                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8743                            }
8744                            else if (articleId.equals(StringPool.BLANK)) {
8745                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8746                            }
8747                            else {
8748                                    bindArticleId = true;
8749    
8750                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8751                            }
8752    
8753                            if (orderByComparator != null) {
8754                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8755                                            orderByComparator);
8756                            }
8757                            else
8758                             if (pagination) {
8759                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8760                            }
8761    
8762                            String sql = query.toString();
8763    
8764                            Session session = null;
8765    
8766                            try {
8767                                    session = openSession();
8768    
8769                                    Query q = session.createQuery(sql);
8770    
8771                                    QueryPos qPos = QueryPos.getInstance(q);
8772    
8773                                    qPos.add(groupId);
8774    
8775                                    if (bindArticleId) {
8776                                            qPos.add(articleId);
8777                                    }
8778    
8779                                    if (!pagination) {
8780                                            list = (List<JournalArticle>)QueryUtil.list(q,
8781                                                            getDialect(), start, end, false);
8782    
8783                                            Collections.sort(list);
8784    
8785                                            list = new UnmodifiableList<JournalArticle>(list);
8786                                    }
8787                                    else {
8788                                            list = (List<JournalArticle>)QueryUtil.list(q,
8789                                                            getDialect(), start, end);
8790                                    }
8791    
8792                                    cacheResult(list);
8793    
8794                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8795                            }
8796                            catch (Exception e) {
8797                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8798    
8799                                    throw processException(e);
8800                            }
8801                            finally {
8802                                    closeSession(session);
8803                            }
8804                    }
8805    
8806                    return list;
8807            }
8808    
8809            /**
8810             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8811             *
8812             * @param groupId the group ID
8813             * @param articleId the article ID
8814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8815             * @return the first matching journal article
8816             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8817             * @throws SystemException if a system exception occurred
8818             */
8819            @Override
8820            public JournalArticle findByG_A_First(long groupId, String articleId,
8821                    OrderByComparator orderByComparator)
8822                    throws NoSuchArticleException, SystemException {
8823                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
8824                                    orderByComparator);
8825    
8826                    if (journalArticle != null) {
8827                            return journalArticle;
8828                    }
8829    
8830                    StringBundler msg = new StringBundler(6);
8831    
8832                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8833    
8834                    msg.append("groupId=");
8835                    msg.append(groupId);
8836    
8837                    msg.append(", articleId=");
8838                    msg.append(articleId);
8839    
8840                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8841    
8842                    throw new NoSuchArticleException(msg.toString());
8843            }
8844    
8845            /**
8846             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8847             *
8848             * @param groupId the group ID
8849             * @param articleId the article ID
8850             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8851             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8852             * @throws SystemException if a system exception occurred
8853             */
8854            @Override
8855            public JournalArticle fetchByG_A_First(long groupId, String articleId,
8856                    OrderByComparator orderByComparator) throws SystemException {
8857                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
8858                                    orderByComparator);
8859    
8860                    if (!list.isEmpty()) {
8861                            return list.get(0);
8862                    }
8863    
8864                    return null;
8865            }
8866    
8867            /**
8868             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8869             *
8870             * @param groupId the group ID
8871             * @param articleId the article ID
8872             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8873             * @return the last matching journal article
8874             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8875             * @throws SystemException if a system exception occurred
8876             */
8877            @Override
8878            public JournalArticle findByG_A_Last(long groupId, String articleId,
8879                    OrderByComparator orderByComparator)
8880                    throws NoSuchArticleException, SystemException {
8881                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
8882                                    orderByComparator);
8883    
8884                    if (journalArticle != null) {
8885                            return journalArticle;
8886                    }
8887    
8888                    StringBundler msg = new StringBundler(6);
8889    
8890                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8891    
8892                    msg.append("groupId=");
8893                    msg.append(groupId);
8894    
8895                    msg.append(", articleId=");
8896                    msg.append(articleId);
8897    
8898                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8899    
8900                    throw new NoSuchArticleException(msg.toString());
8901            }
8902    
8903            /**
8904             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8905             *
8906             * @param groupId the group ID
8907             * @param articleId the article ID
8908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8909             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8910             * @throws SystemException if a system exception occurred
8911             */
8912            @Override
8913            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
8914                    OrderByComparator orderByComparator) throws SystemException {
8915                    int count = countByG_A(groupId, articleId);
8916    
8917                    if (count == 0) {
8918                            return null;
8919                    }
8920    
8921                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
8922                                    count, orderByComparator);
8923    
8924                    if (!list.isEmpty()) {
8925                            return list.get(0);
8926                    }
8927    
8928                    return null;
8929            }
8930    
8931            /**
8932             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8933             *
8934             * @param id the primary key of the current journal article
8935             * @param groupId the group ID
8936             * @param articleId the article ID
8937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8938             * @return the previous, current, and next journal article
8939             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8940             * @throws SystemException if a system exception occurred
8941             */
8942            @Override
8943            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
8944                    String articleId, OrderByComparator orderByComparator)
8945                    throws NoSuchArticleException, SystemException {
8946                    JournalArticle journalArticle = findByPrimaryKey(id);
8947    
8948                    Session session = null;
8949    
8950                    try {
8951                            session = openSession();
8952    
8953                            JournalArticle[] array = new JournalArticleImpl[3];
8954    
8955                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8956                                            articleId, orderByComparator, true);
8957    
8958                            array[1] = journalArticle;
8959    
8960                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8961                                            articleId, orderByComparator, false);
8962    
8963                            return array;
8964                    }
8965                    catch (Exception e) {
8966                            throw processException(e);
8967                    }
8968                    finally {
8969                            closeSession(session);
8970                    }
8971            }
8972    
8973            protected JournalArticle getByG_A_PrevAndNext(Session session,
8974                    JournalArticle journalArticle, long groupId, String articleId,
8975                    OrderByComparator orderByComparator, boolean previous) {
8976                    StringBundler query = null;
8977    
8978                    if (orderByComparator != null) {
8979                            query = new StringBundler(6 +
8980                                            (orderByComparator.getOrderByFields().length * 6));
8981                    }
8982                    else {
8983                            query = new StringBundler(3);
8984                    }
8985    
8986                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8987    
8988                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8989    
8990                    boolean bindArticleId = false;
8991    
8992                    if (articleId == null) {
8993                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8994                    }
8995                    else if (articleId.equals(StringPool.BLANK)) {
8996                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8997                    }
8998                    else {
8999                            bindArticleId = true;
9000    
9001                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9002                    }
9003    
9004                    if (orderByComparator != null) {
9005                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9006    
9007                            if (orderByConditionFields.length > 0) {
9008                                    query.append(WHERE_AND);
9009                            }
9010    
9011                            for (int i = 0; i < orderByConditionFields.length; i++) {
9012                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9013                                    query.append(orderByConditionFields[i]);
9014    
9015                                    if ((i + 1) < orderByConditionFields.length) {
9016                                            if (orderByComparator.isAscending() ^ previous) {
9017                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9018                                            }
9019                                            else {
9020                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9021                                            }
9022                                    }
9023                                    else {
9024                                            if (orderByComparator.isAscending() ^ previous) {
9025                                                    query.append(WHERE_GREATER_THAN);
9026                                            }
9027                                            else {
9028                                                    query.append(WHERE_LESSER_THAN);
9029                                            }
9030                                    }
9031                            }
9032    
9033                            query.append(ORDER_BY_CLAUSE);
9034    
9035                            String[] orderByFields = orderByComparator.getOrderByFields();
9036    
9037                            for (int i = 0; i < orderByFields.length; i++) {
9038                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9039                                    query.append(orderByFields[i]);
9040    
9041                                    if ((i + 1) < orderByFields.length) {
9042                                            if (orderByComparator.isAscending() ^ previous) {
9043                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9044                                            }
9045                                            else {
9046                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9047                                            }
9048                                    }
9049                                    else {
9050                                            if (orderByComparator.isAscending() ^ previous) {
9051                                                    query.append(ORDER_BY_ASC);
9052                                            }
9053                                            else {
9054                                                    query.append(ORDER_BY_DESC);
9055                                            }
9056                                    }
9057                            }
9058                    }
9059                    else {
9060                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9061                    }
9062    
9063                    String sql = query.toString();
9064    
9065                    Query q = session.createQuery(sql);
9066    
9067                    q.setFirstResult(0);
9068                    q.setMaxResults(2);
9069    
9070                    QueryPos qPos = QueryPos.getInstance(q);
9071    
9072                    qPos.add(groupId);
9073    
9074                    if (bindArticleId) {
9075                            qPos.add(articleId);
9076                    }
9077    
9078                    if (orderByComparator != null) {
9079                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9080    
9081                            for (Object value : values) {
9082                                    qPos.add(value);
9083                            }
9084                    }
9085    
9086                    List<JournalArticle> list = q.list();
9087    
9088                    if (list.size() == 2) {
9089                            return list.get(1);
9090                    }
9091                    else {
9092                            return null;
9093                    }
9094            }
9095    
9096            /**
9097             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9098             *
9099             * @param groupId the group ID
9100             * @param articleId the article ID
9101             * @return the matching journal articles that the user has permission to view
9102             * @throws SystemException if a system exception occurred
9103             */
9104            @Override
9105            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
9106                    throws SystemException {
9107                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
9108                            QueryUtil.ALL_POS, null);
9109            }
9110    
9111            /**
9112             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9113             *
9114             * <p>
9115             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9116             * </p>
9117             *
9118             * @param groupId the group ID
9119             * @param articleId the article ID
9120             * @param start the lower bound of the range of journal articles
9121             * @param end the upper bound of the range of journal articles (not inclusive)
9122             * @return the range of matching journal articles that the user has permission to view
9123             * @throws SystemException if a system exception occurred
9124             */
9125            @Override
9126            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9127                    int start, int end) throws SystemException {
9128                    return filterFindByG_A(groupId, articleId, start, end, null);
9129            }
9130    
9131            /**
9132             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
9133             *
9134             * <p>
9135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9136             * </p>
9137             *
9138             * @param groupId the group ID
9139             * @param articleId the article ID
9140             * @param start the lower bound of the range of journal articles
9141             * @param end the upper bound of the range of journal articles (not inclusive)
9142             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9143             * @return the ordered range of matching journal articles that the user has permission to view
9144             * @throws SystemException if a system exception occurred
9145             */
9146            @Override
9147            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9148                    int start, int end, OrderByComparator orderByComparator)
9149                    throws SystemException {
9150                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9151                            return findByG_A(groupId, articleId, start, end, orderByComparator);
9152                    }
9153    
9154                    StringBundler query = null;
9155    
9156                    if (orderByComparator != null) {
9157                            query = new StringBundler(4 +
9158                                            (orderByComparator.getOrderByFields().length * 3));
9159                    }
9160                    else {
9161                            query = new StringBundler(4);
9162                    }
9163    
9164                    if (getDB().isSupportsInlineDistinct()) {
9165                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9166                    }
9167                    else {
9168                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9169                    }
9170    
9171                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9172    
9173                    boolean bindArticleId = false;
9174    
9175                    if (articleId == null) {
9176                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9177                    }
9178                    else if (articleId.equals(StringPool.BLANK)) {
9179                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9180                    }
9181                    else {
9182                            bindArticleId = true;
9183    
9184                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9185                    }
9186    
9187                    if (!getDB().isSupportsInlineDistinct()) {
9188                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9189                    }
9190    
9191                    if (orderByComparator != null) {
9192                            if (getDB().isSupportsInlineDistinct()) {
9193                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9194                                            orderByComparator, true);
9195                            }
9196                            else {
9197                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9198                                            orderByComparator, true);
9199                            }
9200                    }
9201                    else {
9202                            if (getDB().isSupportsInlineDistinct()) {
9203                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9204                            }
9205                            else {
9206                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9207                            }
9208                    }
9209    
9210                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9211                                    JournalArticle.class.getName(),
9212                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9213    
9214                    Session session = null;
9215    
9216                    try {
9217                            session = openSession();
9218    
9219                            SQLQuery q = session.createSQLQuery(sql);
9220    
9221                            if (getDB().isSupportsInlineDistinct()) {
9222                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9223                            }
9224                            else {
9225                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9226                            }
9227    
9228                            QueryPos qPos = QueryPos.getInstance(q);
9229    
9230                            qPos.add(groupId);
9231    
9232                            if (bindArticleId) {
9233                                    qPos.add(articleId);
9234                            }
9235    
9236                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9237                                    end);
9238                    }
9239                    catch (Exception e) {
9240                            throw processException(e);
9241                    }
9242                    finally {
9243                            closeSession(session);
9244                    }
9245            }
9246    
9247            /**
9248             * 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;.
9249             *
9250             * @param id the primary key of the current journal article
9251             * @param groupId the group ID
9252             * @param articleId the article ID
9253             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9254             * @return the previous, current, and next journal article
9255             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9256             * @throws SystemException if a system exception occurred
9257             */
9258            @Override
9259            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
9260                    String articleId, OrderByComparator orderByComparator)
9261                    throws NoSuchArticleException, SystemException {
9262                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9263                            return findByG_A_PrevAndNext(id, groupId, articleId,
9264                                    orderByComparator);
9265                    }
9266    
9267                    JournalArticle journalArticle = findByPrimaryKey(id);
9268    
9269                    Session session = null;
9270    
9271                    try {
9272                            session = openSession();
9273    
9274                            JournalArticle[] array = new JournalArticleImpl[3];
9275    
9276                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
9277                                            groupId, articleId, orderByComparator, true);
9278    
9279                            array[1] = journalArticle;
9280    
9281                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
9282                                            groupId, articleId, orderByComparator, false);
9283    
9284                            return array;
9285                    }
9286                    catch (Exception e) {
9287                            throw processException(e);
9288                    }
9289                    finally {
9290                            closeSession(session);
9291                    }
9292            }
9293    
9294            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
9295                    JournalArticle journalArticle, long groupId, String articleId,
9296                    OrderByComparator orderByComparator, boolean previous) {
9297                    StringBundler query = null;
9298    
9299                    if (orderByComparator != null) {
9300                            query = new StringBundler(6 +
9301                                            (orderByComparator.getOrderByFields().length * 6));
9302                    }
9303                    else {
9304                            query = new StringBundler(3);
9305                    }
9306    
9307                    if (getDB().isSupportsInlineDistinct()) {
9308                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9309                    }
9310                    else {
9311                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9312                    }
9313    
9314                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9315    
9316                    boolean bindArticleId = false;
9317    
9318                    if (articleId == null) {
9319                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9320                    }
9321                    else if (articleId.equals(StringPool.BLANK)) {
9322                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9323                    }
9324                    else {
9325                            bindArticleId = true;
9326    
9327                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9328                    }
9329    
9330                    if (!getDB().isSupportsInlineDistinct()) {
9331                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9332                    }
9333    
9334                    if (orderByComparator != null) {
9335                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9336    
9337                            if (orderByConditionFields.length > 0) {
9338                                    query.append(WHERE_AND);
9339                            }
9340    
9341                            for (int i = 0; i < orderByConditionFields.length; i++) {
9342                                    if (getDB().isSupportsInlineDistinct()) {
9343                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9344                                    }
9345                                    else {
9346                                            query.append(_ORDER_BY_ENTITY_TABLE);
9347                                    }
9348    
9349                                    query.append(orderByConditionFields[i]);
9350    
9351                                    if ((i + 1) < orderByConditionFields.length) {
9352                                            if (orderByComparator.isAscending() ^ previous) {
9353                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9354                                            }
9355                                            else {
9356                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9357                                            }
9358                                    }
9359                                    else {
9360                                            if (orderByComparator.isAscending() ^ previous) {
9361                                                    query.append(WHERE_GREATER_THAN);
9362                                            }
9363                                            else {
9364                                                    query.append(WHERE_LESSER_THAN);
9365                                            }
9366                                    }
9367                            }
9368    
9369                            query.append(ORDER_BY_CLAUSE);
9370    
9371                            String[] orderByFields = orderByComparator.getOrderByFields();
9372    
9373                            for (int i = 0; i < orderByFields.length; i++) {
9374                                    if (getDB().isSupportsInlineDistinct()) {
9375                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9376                                    }
9377                                    else {
9378                                            query.append(_ORDER_BY_ENTITY_TABLE);
9379                                    }
9380    
9381                                    query.append(orderByFields[i]);
9382    
9383                                    if ((i + 1) < orderByFields.length) {
9384                                            if (orderByComparator.isAscending() ^ previous) {
9385                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9386                                            }
9387                                            else {
9388                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9389                                            }
9390                                    }
9391                                    else {
9392                                            if (orderByComparator.isAscending() ^ previous) {
9393                                                    query.append(ORDER_BY_ASC);
9394                                            }
9395                                            else {
9396                                                    query.append(ORDER_BY_DESC);
9397                                            }
9398                                    }
9399                            }
9400                    }
9401                    else {
9402                            if (getDB().isSupportsInlineDistinct()) {
9403                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9404                            }
9405                            else {
9406                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9407                            }
9408                    }
9409    
9410                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9411                                    JournalArticle.class.getName(),
9412                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9413    
9414                    SQLQuery q = session.createSQLQuery(sql);
9415    
9416                    q.setFirstResult(0);
9417                    q.setMaxResults(2);
9418    
9419                    if (getDB().isSupportsInlineDistinct()) {
9420                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9421                    }
9422                    else {
9423                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9424                    }
9425    
9426                    QueryPos qPos = QueryPos.getInstance(q);
9427    
9428                    qPos.add(groupId);
9429    
9430                    if (bindArticleId) {
9431                            qPos.add(articleId);
9432                    }
9433    
9434                    if (orderByComparator != null) {
9435                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9436    
9437                            for (Object value : values) {
9438                                    qPos.add(value);
9439                            }
9440                    }
9441    
9442                    List<JournalArticle> list = q.list();
9443    
9444                    if (list.size() == 2) {
9445                            return list.get(1);
9446                    }
9447                    else {
9448                            return null;
9449                    }
9450            }
9451    
9452            /**
9453             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
9454             *
9455             * @param groupId the group ID
9456             * @param articleId the article ID
9457             * @throws SystemException if a system exception occurred
9458             */
9459            @Override
9460            public void removeByG_A(long groupId, String articleId)
9461                    throws SystemException {
9462                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
9463                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9464                            remove(journalArticle);
9465                    }
9466            }
9467    
9468            /**
9469             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
9470             *
9471             * @param groupId the group ID
9472             * @param articleId the article ID
9473             * @return the number of matching journal articles
9474             * @throws SystemException if a system exception occurred
9475             */
9476            @Override
9477            public int countByG_A(long groupId, String articleId)
9478                    throws SystemException {
9479                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
9480    
9481                    Object[] finderArgs = new Object[] { groupId, articleId };
9482    
9483                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9484                                    this);
9485    
9486                    if (count == null) {
9487                            StringBundler query = new StringBundler(3);
9488    
9489                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9490    
9491                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9492    
9493                            boolean bindArticleId = false;
9494    
9495                            if (articleId == null) {
9496                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9497                            }
9498                            else if (articleId.equals(StringPool.BLANK)) {
9499                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9500                            }
9501                            else {
9502                                    bindArticleId = true;
9503    
9504                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9505                            }
9506    
9507                            String sql = query.toString();
9508    
9509                            Session session = null;
9510    
9511                            try {
9512                                    session = openSession();
9513    
9514                                    Query q = session.createQuery(sql);
9515    
9516                                    QueryPos qPos = QueryPos.getInstance(q);
9517    
9518                                    qPos.add(groupId);
9519    
9520                                    if (bindArticleId) {
9521                                            qPos.add(articleId);
9522                                    }
9523    
9524                                    count = (Long)q.uniqueResult();
9525    
9526                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9527                            }
9528                            catch (Exception e) {
9529                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9530    
9531                                    throw processException(e);
9532                            }
9533                            finally {
9534                                    closeSession(session);
9535                            }
9536                    }
9537    
9538                    return count.intValue();
9539            }
9540    
9541            /**
9542             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9543             *
9544             * @param groupId the group ID
9545             * @param articleId the article ID
9546             * @return the number of matching journal articles that the user has permission to view
9547             * @throws SystemException if a system exception occurred
9548             */
9549            @Override
9550            public int filterCountByG_A(long groupId, String articleId)
9551                    throws SystemException {
9552                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9553                            return countByG_A(groupId, articleId);
9554                    }
9555    
9556                    StringBundler query = new StringBundler(3);
9557    
9558                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9559    
9560                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9561    
9562                    boolean bindArticleId = false;
9563    
9564                    if (articleId == null) {
9565                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9566                    }
9567                    else if (articleId.equals(StringPool.BLANK)) {
9568                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9569                    }
9570                    else {
9571                            bindArticleId = true;
9572    
9573                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9574                    }
9575    
9576                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9577                                    JournalArticle.class.getName(),
9578                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9579    
9580                    Session session = null;
9581    
9582                    try {
9583                            session = openSession();
9584    
9585                            SQLQuery q = session.createSQLQuery(sql);
9586    
9587                            q.addScalar(COUNT_COLUMN_NAME,
9588                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9589    
9590                            QueryPos qPos = QueryPos.getInstance(q);
9591    
9592                            qPos.add(groupId);
9593    
9594                            if (bindArticleId) {
9595                                    qPos.add(articleId);
9596                            }
9597    
9598                            Long count = (Long)q.uniqueResult();
9599    
9600                            return count.intValue();
9601                    }
9602                    catch (Exception e) {
9603                            throw processException(e);
9604                    }
9605                    finally {
9606                            closeSession(session);
9607                    }
9608            }
9609    
9610            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
9611            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
9612            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
9613            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
9614            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9615                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9616                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9617                            "findByG_UT",
9618                            new String[] {
9619                                    Long.class.getName(), String.class.getName(),
9620                                    
9621                            Integer.class.getName(), Integer.class.getName(),
9622                                    OrderByComparator.class.getName()
9623                            });
9624            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9625                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9626                            JournalArticleImpl.class,
9627                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
9628                            new String[] { Long.class.getName(), String.class.getName() },
9629                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9630                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
9631                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9632                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9633            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9634                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9635                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
9636                            new String[] { Long.class.getName(), String.class.getName() });
9637    
9638            /**
9639             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
9640             *
9641             * @param groupId the group ID
9642             * @param urlTitle the url title
9643             * @return the matching journal articles
9644             * @throws SystemException if a system exception occurred
9645             */
9646            @Override
9647            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
9648                    throws SystemException {
9649                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9650                            QueryUtil.ALL_POS, null);
9651            }
9652    
9653            /**
9654             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9655             *
9656             * <p>
9657             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9658             * </p>
9659             *
9660             * @param groupId the group ID
9661             * @param urlTitle the url title
9662             * @param start the lower bound of the range of journal articles
9663             * @param end the upper bound of the range of journal articles (not inclusive)
9664             * @return the range of matching journal articles
9665             * @throws SystemException if a system exception occurred
9666             */
9667            @Override
9668            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9669                    int start, int end) throws SystemException {
9670                    return findByG_UT(groupId, urlTitle, start, end, null);
9671            }
9672    
9673            /**
9674             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9675             *
9676             * <p>
9677             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9678             * </p>
9679             *
9680             * @param groupId the group ID
9681             * @param urlTitle the url title
9682             * @param start the lower bound of the range of journal articles
9683             * @param end the upper bound of the range of journal articles (not inclusive)
9684             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9685             * @return the ordered range of matching journal articles
9686             * @throws SystemException if a system exception occurred
9687             */
9688            @Override
9689            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9690                    int start, int end, OrderByComparator orderByComparator)
9691                    throws SystemException {
9692                    boolean pagination = true;
9693                    FinderPath finderPath = null;
9694                    Object[] finderArgs = null;
9695    
9696                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9697                                    (orderByComparator == null)) {
9698                            pagination = false;
9699                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
9700                            finderArgs = new Object[] { groupId, urlTitle };
9701                    }
9702                    else {
9703                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
9704                            finderArgs = new Object[] {
9705                                            groupId, urlTitle,
9706                                            
9707                                            start, end, orderByComparator
9708                                    };
9709                    }
9710    
9711                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9712                                    finderArgs, this);
9713    
9714                    if ((list != null) && !list.isEmpty()) {
9715                            for (JournalArticle journalArticle : list) {
9716                                    if ((groupId != journalArticle.getGroupId()) ||
9717                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
9718                                            list = null;
9719    
9720                                            break;
9721                                    }
9722                            }
9723                    }
9724    
9725                    if (list == null) {
9726                            StringBundler query = null;
9727    
9728                            if (orderByComparator != null) {
9729                                    query = new StringBundler(4 +
9730                                                    (orderByComparator.getOrderByFields().length * 3));
9731                            }
9732                            else {
9733                                    query = new StringBundler(4);
9734                            }
9735    
9736                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9737    
9738                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9739    
9740                            boolean bindUrlTitle = false;
9741    
9742                            if (urlTitle == null) {
9743                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9744                            }
9745                            else if (urlTitle.equals(StringPool.BLANK)) {
9746                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9747                            }
9748                            else {
9749                                    bindUrlTitle = true;
9750    
9751                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9752                            }
9753    
9754                            if (orderByComparator != null) {
9755                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9756                                            orderByComparator);
9757                            }
9758                            else
9759                             if (pagination) {
9760                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9761                            }
9762    
9763                            String sql = query.toString();
9764    
9765                            Session session = null;
9766    
9767                            try {
9768                                    session = openSession();
9769    
9770                                    Query q = session.createQuery(sql);
9771    
9772                                    QueryPos qPos = QueryPos.getInstance(q);
9773    
9774                                    qPos.add(groupId);
9775    
9776                                    if (bindUrlTitle) {
9777                                            qPos.add(urlTitle);
9778                                    }
9779    
9780                                    if (!pagination) {
9781                                            list = (List<JournalArticle>)QueryUtil.list(q,
9782                                                            getDialect(), start, end, false);
9783    
9784                                            Collections.sort(list);
9785    
9786                                            list = new UnmodifiableList<JournalArticle>(list);
9787                                    }
9788                                    else {
9789                                            list = (List<JournalArticle>)QueryUtil.list(q,
9790                                                            getDialect(), start, end);
9791                                    }
9792    
9793                                    cacheResult(list);
9794    
9795                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9796                            }
9797                            catch (Exception e) {
9798                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9799    
9800                                    throw processException(e);
9801                            }
9802                            finally {
9803                                    closeSession(session);
9804                            }
9805                    }
9806    
9807                    return list;
9808            }
9809    
9810            /**
9811             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9812             *
9813             * @param groupId the group ID
9814             * @param urlTitle the url title
9815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9816             * @return the first matching journal article
9817             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9818             * @throws SystemException if a system exception occurred
9819             */
9820            @Override
9821            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
9822                    OrderByComparator orderByComparator)
9823                    throws NoSuchArticleException, SystemException {
9824                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
9825                                    orderByComparator);
9826    
9827                    if (journalArticle != null) {
9828                            return journalArticle;
9829                    }
9830    
9831                    StringBundler msg = new StringBundler(6);
9832    
9833                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9834    
9835                    msg.append("groupId=");
9836                    msg.append(groupId);
9837    
9838                    msg.append(", urlTitle=");
9839                    msg.append(urlTitle);
9840    
9841                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9842    
9843                    throw new NoSuchArticleException(msg.toString());
9844            }
9845    
9846            /**
9847             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9848             *
9849             * @param groupId the group ID
9850             * @param urlTitle the url title
9851             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9852             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9853             * @throws SystemException if a system exception occurred
9854             */
9855            @Override
9856            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
9857                    OrderByComparator orderByComparator) throws SystemException {
9858                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
9859                                    orderByComparator);
9860    
9861                    if (!list.isEmpty()) {
9862                            return list.get(0);
9863                    }
9864    
9865                    return null;
9866            }
9867    
9868            /**
9869             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9870             *
9871             * @param groupId the group ID
9872             * @param urlTitle the url title
9873             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9874             * @return the last matching journal article
9875             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9876             * @throws SystemException if a system exception occurred
9877             */
9878            @Override
9879            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
9880                    OrderByComparator orderByComparator)
9881                    throws NoSuchArticleException, SystemException {
9882                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
9883                                    orderByComparator);
9884    
9885                    if (journalArticle != null) {
9886                            return journalArticle;
9887                    }
9888    
9889                    StringBundler msg = new StringBundler(6);
9890    
9891                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9892    
9893                    msg.append("groupId=");
9894                    msg.append(groupId);
9895    
9896                    msg.append(", urlTitle=");
9897                    msg.append(urlTitle);
9898    
9899                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9900    
9901                    throw new NoSuchArticleException(msg.toString());
9902            }
9903    
9904            /**
9905             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9906             *
9907             * @param groupId the group ID
9908             * @param urlTitle the url title
9909             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9910             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9911             * @throws SystemException if a system exception occurred
9912             */
9913            @Override
9914            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
9915                    OrderByComparator orderByComparator) throws SystemException {
9916                    int count = countByG_UT(groupId, urlTitle);
9917    
9918                    if (count == 0) {
9919                            return null;
9920                    }
9921    
9922                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
9923                                    count, orderByComparator);
9924    
9925                    if (!list.isEmpty()) {
9926                            return list.get(0);
9927                    }
9928    
9929                    return null;
9930            }
9931    
9932            /**
9933             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9934             *
9935             * @param id the primary key of the current journal article
9936             * @param groupId the group ID
9937             * @param urlTitle the url title
9938             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9939             * @return the previous, current, and next journal article
9940             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9941             * @throws SystemException if a system exception occurred
9942             */
9943            @Override
9944            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
9945                    String urlTitle, OrderByComparator orderByComparator)
9946                    throws NoSuchArticleException, SystemException {
9947                    JournalArticle journalArticle = findByPrimaryKey(id);
9948    
9949                    Session session = null;
9950    
9951                    try {
9952                            session = openSession();
9953    
9954                            JournalArticle[] array = new JournalArticleImpl[3];
9955    
9956                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9957                                            urlTitle, orderByComparator, true);
9958    
9959                            array[1] = journalArticle;
9960    
9961                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9962                                            urlTitle, orderByComparator, false);
9963    
9964                            return array;
9965                    }
9966                    catch (Exception e) {
9967                            throw processException(e);
9968                    }
9969                    finally {
9970                            closeSession(session);
9971                    }
9972            }
9973    
9974            protected JournalArticle getByG_UT_PrevAndNext(Session session,
9975                    JournalArticle journalArticle, long groupId, String urlTitle,
9976                    OrderByComparator orderByComparator, boolean previous) {
9977                    StringBundler query = null;
9978    
9979                    if (orderByComparator != null) {
9980                            query = new StringBundler(6 +
9981                                            (orderByComparator.getOrderByFields().length * 6));
9982                    }
9983                    else {
9984                            query = new StringBundler(3);
9985                    }
9986    
9987                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9988    
9989                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9990    
9991                    boolean bindUrlTitle = false;
9992    
9993                    if (urlTitle == null) {
9994                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9995                    }
9996                    else if (urlTitle.equals(StringPool.BLANK)) {
9997                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9998                    }
9999                    else {
10000                            bindUrlTitle = true;
10001    
10002                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10003                    }
10004    
10005                    if (orderByComparator != null) {
10006                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10007    
10008                            if (orderByConditionFields.length > 0) {
10009                                    query.append(WHERE_AND);
10010                            }
10011    
10012                            for (int i = 0; i < orderByConditionFields.length; i++) {
10013                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10014                                    query.append(orderByConditionFields[i]);
10015    
10016                                    if ((i + 1) < orderByConditionFields.length) {
10017                                            if (orderByComparator.isAscending() ^ previous) {
10018                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10019                                            }
10020                                            else {
10021                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10022                                            }
10023                                    }
10024                                    else {
10025                                            if (orderByComparator.isAscending() ^ previous) {
10026                                                    query.append(WHERE_GREATER_THAN);
10027                                            }
10028                                            else {
10029                                                    query.append(WHERE_LESSER_THAN);
10030                                            }
10031                                    }
10032                            }
10033    
10034                            query.append(ORDER_BY_CLAUSE);
10035    
10036                            String[] orderByFields = orderByComparator.getOrderByFields();
10037    
10038                            for (int i = 0; i < orderByFields.length; i++) {
10039                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10040                                    query.append(orderByFields[i]);
10041    
10042                                    if ((i + 1) < orderByFields.length) {
10043                                            if (orderByComparator.isAscending() ^ previous) {
10044                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10045                                            }
10046                                            else {
10047                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10048                                            }
10049                                    }
10050                                    else {
10051                                            if (orderByComparator.isAscending() ^ previous) {
10052                                                    query.append(ORDER_BY_ASC);
10053                                            }
10054                                            else {
10055                                                    query.append(ORDER_BY_DESC);
10056                                            }
10057                                    }
10058                            }
10059                    }
10060                    else {
10061                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10062                    }
10063    
10064                    String sql = query.toString();
10065    
10066                    Query q = session.createQuery(sql);
10067    
10068                    q.setFirstResult(0);
10069                    q.setMaxResults(2);
10070    
10071                    QueryPos qPos = QueryPos.getInstance(q);
10072    
10073                    qPos.add(groupId);
10074    
10075                    if (bindUrlTitle) {
10076                            qPos.add(urlTitle);
10077                    }
10078    
10079                    if (orderByComparator != null) {
10080                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10081    
10082                            for (Object value : values) {
10083                                    qPos.add(value);
10084                            }
10085                    }
10086    
10087                    List<JournalArticle> list = q.list();
10088    
10089                    if (list.size() == 2) {
10090                            return list.get(1);
10091                    }
10092                    else {
10093                            return null;
10094                    }
10095            }
10096    
10097            /**
10098             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10099             *
10100             * @param groupId the group ID
10101             * @param urlTitle the url title
10102             * @return the matching journal articles that the user has permission to view
10103             * @throws SystemException if a system exception occurred
10104             */
10105            @Override
10106            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
10107                    throws SystemException {
10108                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10109                            QueryUtil.ALL_POS, null);
10110            }
10111    
10112            /**
10113             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10114             *
10115             * <p>
10116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10117             * </p>
10118             *
10119             * @param groupId the group ID
10120             * @param urlTitle the url title
10121             * @param start the lower bound of the range of journal articles
10122             * @param end the upper bound of the range of journal articles (not inclusive)
10123             * @return the range of matching journal articles that the user has permission to view
10124             * @throws SystemException if a system exception occurred
10125             */
10126            @Override
10127            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10128                    int start, int end) throws SystemException {
10129                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
10130            }
10131    
10132            /**
10133             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
10134             *
10135             * <p>
10136             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10137             * </p>
10138             *
10139             * @param groupId the group ID
10140             * @param urlTitle the url title
10141             * @param start the lower bound of the range of journal articles
10142             * @param end the upper bound of the range of journal articles (not inclusive)
10143             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10144             * @return the ordered range of matching journal articles that the user has permission to view
10145             * @throws SystemException if a system exception occurred
10146             */
10147            @Override
10148            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10149                    int start, int end, OrderByComparator orderByComparator)
10150                    throws SystemException {
10151                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10152                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
10153                    }
10154    
10155                    StringBundler query = null;
10156    
10157                    if (orderByComparator != null) {
10158                            query = new StringBundler(4 +
10159                                            (orderByComparator.getOrderByFields().length * 3));
10160                    }
10161                    else {
10162                            query = new StringBundler(4);
10163                    }
10164    
10165                    if (getDB().isSupportsInlineDistinct()) {
10166                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10167                    }
10168                    else {
10169                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10170                    }
10171    
10172                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10173    
10174                    boolean bindUrlTitle = false;
10175    
10176                    if (urlTitle == null) {
10177                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10178                    }
10179                    else if (urlTitle.equals(StringPool.BLANK)) {
10180                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10181                    }
10182                    else {
10183                            bindUrlTitle = true;
10184    
10185                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10186                    }
10187    
10188                    if (!getDB().isSupportsInlineDistinct()) {
10189                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10190                    }
10191    
10192                    if (orderByComparator != null) {
10193                            if (getDB().isSupportsInlineDistinct()) {
10194                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10195                                            orderByComparator, true);
10196                            }
10197                            else {
10198                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10199                                            orderByComparator, true);
10200                            }
10201                    }
10202                    else {
10203                            if (getDB().isSupportsInlineDistinct()) {
10204                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10205                            }
10206                            else {
10207                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10208                            }
10209                    }
10210    
10211                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10212                                    JournalArticle.class.getName(),
10213                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10214    
10215                    Session session = null;
10216    
10217                    try {
10218                            session = openSession();
10219    
10220                            SQLQuery q = session.createSQLQuery(sql);
10221    
10222                            if (getDB().isSupportsInlineDistinct()) {
10223                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10224                            }
10225                            else {
10226                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10227                            }
10228    
10229                            QueryPos qPos = QueryPos.getInstance(q);
10230    
10231                            qPos.add(groupId);
10232    
10233                            if (bindUrlTitle) {
10234                                    qPos.add(urlTitle);
10235                            }
10236    
10237                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10238                                    end);
10239                    }
10240                    catch (Exception e) {
10241                            throw processException(e);
10242                    }
10243                    finally {
10244                            closeSession(session);
10245                    }
10246            }
10247    
10248            /**
10249             * 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;.
10250             *
10251             * @param id the primary key of the current journal article
10252             * @param groupId the group ID
10253             * @param urlTitle the url title
10254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10255             * @return the previous, current, and next journal article
10256             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10257             * @throws SystemException if a system exception occurred
10258             */
10259            @Override
10260            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
10261                    String urlTitle, OrderByComparator orderByComparator)
10262                    throws NoSuchArticleException, SystemException {
10263                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10264                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
10265                                    orderByComparator);
10266                    }
10267    
10268                    JournalArticle journalArticle = findByPrimaryKey(id);
10269    
10270                    Session session = null;
10271    
10272                    try {
10273                            session = openSession();
10274    
10275                            JournalArticle[] array = new JournalArticleImpl[3];
10276    
10277                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10278                                            groupId, urlTitle, orderByComparator, true);
10279    
10280                            array[1] = journalArticle;
10281    
10282                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10283                                            groupId, urlTitle, orderByComparator, false);
10284    
10285                            return array;
10286                    }
10287                    catch (Exception e) {
10288                            throw processException(e);
10289                    }
10290                    finally {
10291                            closeSession(session);
10292                    }
10293            }
10294    
10295            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
10296                    JournalArticle journalArticle, long groupId, String urlTitle,
10297                    OrderByComparator orderByComparator, boolean previous) {
10298                    StringBundler query = null;
10299    
10300                    if (orderByComparator != null) {
10301                            query = new StringBundler(6 +
10302                                            (orderByComparator.getOrderByFields().length * 6));
10303                    }
10304                    else {
10305                            query = new StringBundler(3);
10306                    }
10307    
10308                    if (getDB().isSupportsInlineDistinct()) {
10309                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10310                    }
10311                    else {
10312                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10313                    }
10314    
10315                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10316    
10317                    boolean bindUrlTitle = false;
10318    
10319                    if (urlTitle == null) {
10320                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10321                    }
10322                    else if (urlTitle.equals(StringPool.BLANK)) {
10323                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10324                    }
10325                    else {
10326                            bindUrlTitle = true;
10327    
10328                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10329                    }
10330    
10331                    if (!getDB().isSupportsInlineDistinct()) {
10332                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10333                    }
10334    
10335                    if (orderByComparator != null) {
10336                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10337    
10338                            if (orderByConditionFields.length > 0) {
10339                                    query.append(WHERE_AND);
10340                            }
10341    
10342                            for (int i = 0; i < orderByConditionFields.length; i++) {
10343                                    if (getDB().isSupportsInlineDistinct()) {
10344                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10345                                    }
10346                                    else {
10347                                            query.append(_ORDER_BY_ENTITY_TABLE);
10348                                    }
10349    
10350                                    query.append(orderByConditionFields[i]);
10351    
10352                                    if ((i + 1) < orderByConditionFields.length) {
10353                                            if (orderByComparator.isAscending() ^ previous) {
10354                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10355                                            }
10356                                            else {
10357                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10358                                            }
10359                                    }
10360                                    else {
10361                                            if (orderByComparator.isAscending() ^ previous) {
10362                                                    query.append(WHERE_GREATER_THAN);
10363                                            }
10364                                            else {
10365                                                    query.append(WHERE_LESSER_THAN);
10366                                            }
10367                                    }
10368                            }
10369    
10370                            query.append(ORDER_BY_CLAUSE);
10371    
10372                            String[] orderByFields = orderByComparator.getOrderByFields();
10373    
10374                            for (int i = 0; i < orderByFields.length; i++) {
10375                                    if (getDB().isSupportsInlineDistinct()) {
10376                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10377                                    }
10378                                    else {
10379                                            query.append(_ORDER_BY_ENTITY_TABLE);
10380                                    }
10381    
10382                                    query.append(orderByFields[i]);
10383    
10384                                    if ((i + 1) < orderByFields.length) {
10385                                            if (orderByComparator.isAscending() ^ previous) {
10386                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10387                                            }
10388                                            else {
10389                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10390                                            }
10391                                    }
10392                                    else {
10393                                            if (orderByComparator.isAscending() ^ previous) {
10394                                                    query.append(ORDER_BY_ASC);
10395                                            }
10396                                            else {
10397                                                    query.append(ORDER_BY_DESC);
10398                                            }
10399                                    }
10400                            }
10401                    }
10402                    else {
10403                            if (getDB().isSupportsInlineDistinct()) {
10404                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10405                            }
10406                            else {
10407                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10408                            }
10409                    }
10410    
10411                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10412                                    JournalArticle.class.getName(),
10413                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10414    
10415                    SQLQuery q = session.createSQLQuery(sql);
10416    
10417                    q.setFirstResult(0);
10418                    q.setMaxResults(2);
10419    
10420                    if (getDB().isSupportsInlineDistinct()) {
10421                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10422                    }
10423                    else {
10424                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10425                    }
10426    
10427                    QueryPos qPos = QueryPos.getInstance(q);
10428    
10429                    qPos.add(groupId);
10430    
10431                    if (bindUrlTitle) {
10432                            qPos.add(urlTitle);
10433                    }
10434    
10435                    if (orderByComparator != null) {
10436                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10437    
10438                            for (Object value : values) {
10439                                    qPos.add(value);
10440                            }
10441                    }
10442    
10443                    List<JournalArticle> list = q.list();
10444    
10445                    if (list.size() == 2) {
10446                            return list.get(1);
10447                    }
10448                    else {
10449                            return null;
10450                    }
10451            }
10452    
10453            /**
10454             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
10455             *
10456             * @param groupId the group ID
10457             * @param urlTitle the url title
10458             * @throws SystemException if a system exception occurred
10459             */
10460            @Override
10461            public void removeByG_UT(long groupId, String urlTitle)
10462                    throws SystemException {
10463                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
10464                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10465                            remove(journalArticle);
10466                    }
10467            }
10468    
10469            /**
10470             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
10471             *
10472             * @param groupId the group ID
10473             * @param urlTitle the url title
10474             * @return the number of matching journal articles
10475             * @throws SystemException if a system exception occurred
10476             */
10477            @Override
10478            public int countByG_UT(long groupId, String urlTitle)
10479                    throws SystemException {
10480                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
10481    
10482                    Object[] finderArgs = new Object[] { groupId, urlTitle };
10483    
10484                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10485                                    this);
10486    
10487                    if (count == null) {
10488                            StringBundler query = new StringBundler(3);
10489    
10490                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10491    
10492                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10493    
10494                            boolean bindUrlTitle = false;
10495    
10496                            if (urlTitle == null) {
10497                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10498                            }
10499                            else if (urlTitle.equals(StringPool.BLANK)) {
10500                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10501                            }
10502                            else {
10503                                    bindUrlTitle = true;
10504    
10505                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10506                            }
10507    
10508                            String sql = query.toString();
10509    
10510                            Session session = null;
10511    
10512                            try {
10513                                    session = openSession();
10514    
10515                                    Query q = session.createQuery(sql);
10516    
10517                                    QueryPos qPos = QueryPos.getInstance(q);
10518    
10519                                    qPos.add(groupId);
10520    
10521                                    if (bindUrlTitle) {
10522                                            qPos.add(urlTitle);
10523                                    }
10524    
10525                                    count = (Long)q.uniqueResult();
10526    
10527                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10528                            }
10529                            catch (Exception e) {
10530                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10531    
10532                                    throw processException(e);
10533                            }
10534                            finally {
10535                                    closeSession(session);
10536                            }
10537                    }
10538    
10539                    return count.intValue();
10540            }
10541    
10542            /**
10543             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10544             *
10545             * @param groupId the group ID
10546             * @param urlTitle the url title
10547             * @return the number of matching journal articles that the user has permission to view
10548             * @throws SystemException if a system exception occurred
10549             */
10550            @Override
10551            public int filterCountByG_UT(long groupId, String urlTitle)
10552                    throws SystemException {
10553                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10554                            return countByG_UT(groupId, urlTitle);
10555                    }
10556    
10557                    StringBundler query = new StringBundler(3);
10558    
10559                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10560    
10561                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10562    
10563                    boolean bindUrlTitle = false;
10564    
10565                    if (urlTitle == null) {
10566                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10567                    }
10568                    else if (urlTitle.equals(StringPool.BLANK)) {
10569                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10570                    }
10571                    else {
10572                            bindUrlTitle = true;
10573    
10574                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10575                    }
10576    
10577                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10578                                    JournalArticle.class.getName(),
10579                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10580    
10581                    Session session = null;
10582    
10583                    try {
10584                            session = openSession();
10585    
10586                            SQLQuery q = session.createSQLQuery(sql);
10587    
10588                            q.addScalar(COUNT_COLUMN_NAME,
10589                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10590    
10591                            QueryPos qPos = QueryPos.getInstance(q);
10592    
10593                            qPos.add(groupId);
10594    
10595                            if (bindUrlTitle) {
10596                                    qPos.add(urlTitle);
10597                            }
10598    
10599                            Long count = (Long)q.uniqueResult();
10600    
10601                            return count.intValue();
10602                    }
10603                    catch (Exception e) {
10604                            throw processException(e);
10605                    }
10606                    finally {
10607                            closeSession(session);
10608                    }
10609            }
10610    
10611            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
10612            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
10613            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
10614            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
10615            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10616                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10617                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10618                            "findByG_S",
10619                            new String[] {
10620                                    Long.class.getName(), String.class.getName(),
10621                                    
10622                            Integer.class.getName(), Integer.class.getName(),
10623                                    OrderByComparator.class.getName()
10624                            });
10625            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10626                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10627                            JournalArticleImpl.class,
10628                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
10629                            new String[] { Long.class.getName(), String.class.getName() },
10630                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10631                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
10632                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10633                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10634            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10635                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10636                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
10637                            new String[] { Long.class.getName(), String.class.getName() });
10638    
10639            /**
10640             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
10641             *
10642             * @param groupId the group ID
10643             * @param structureId the structure ID
10644             * @return the matching journal articles
10645             * @throws SystemException if a system exception occurred
10646             */
10647            @Override
10648            public List<JournalArticle> findByG_S(long groupId, String structureId)
10649                    throws SystemException {
10650                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
10651                            QueryUtil.ALL_POS, null);
10652            }
10653    
10654            /**
10655             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
10656             *
10657             * <p>
10658             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10659             * </p>
10660             *
10661             * @param groupId the group ID
10662             * @param structureId the structure ID
10663             * @param start the lower bound of the range of journal articles
10664             * @param end the upper bound of the range of journal articles (not inclusive)
10665             * @return the range of matching journal articles
10666             * @throws SystemException if a system exception occurred
10667             */
10668            @Override
10669            public List<JournalArticle> findByG_S(long groupId, String structureId,
10670                    int start, int end) throws SystemException {
10671                    return findByG_S(groupId, structureId, start, end, null);
10672            }
10673    
10674            /**
10675             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
10676             *
10677             * <p>
10678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10679             * </p>
10680             *
10681             * @param groupId the group ID
10682             * @param structureId the structure ID
10683             * @param start the lower bound of the range of journal articles
10684             * @param end the upper bound of the range of journal articles (not inclusive)
10685             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10686             * @return the ordered range of matching journal articles
10687             * @throws SystemException if a system exception occurred
10688             */
10689            @Override
10690            public List<JournalArticle> findByG_S(long groupId, String structureId,
10691                    int start, int end, OrderByComparator orderByComparator)
10692                    throws SystemException {
10693                    boolean pagination = true;
10694                    FinderPath finderPath = null;
10695                    Object[] finderArgs = null;
10696    
10697                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10698                                    (orderByComparator == null)) {
10699                            pagination = false;
10700                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
10701                            finderArgs = new Object[] { groupId, structureId };
10702                    }
10703                    else {
10704                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
10705                            finderArgs = new Object[] {
10706                                            groupId, structureId,
10707                                            
10708                                            start, end, orderByComparator
10709                                    };
10710                    }
10711    
10712                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10713                                    finderArgs, this);
10714    
10715                    if ((list != null) && !list.isEmpty()) {
10716                            for (JournalArticle journalArticle : list) {
10717                                    if ((groupId != journalArticle.getGroupId()) ||
10718                                                    !Validator.equals(structureId,
10719                                                            journalArticle.getStructureId())) {
10720                                            list = null;
10721    
10722                                            break;
10723                                    }
10724                            }
10725                    }
10726    
10727                    if (list == null) {
10728                            StringBundler query = null;
10729    
10730                            if (orderByComparator != null) {
10731                                    query = new StringBundler(4 +
10732                                                    (orderByComparator.getOrderByFields().length * 3));
10733                            }
10734                            else {
10735                                    query = new StringBundler(4);
10736                            }
10737    
10738                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10739    
10740                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10741    
10742                            boolean bindStructureId = false;
10743    
10744                            if (structureId == null) {
10745                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10746                            }
10747                            else if (structureId.equals(StringPool.BLANK)) {
10748                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10749                            }
10750                            else {
10751                                    bindStructureId = true;
10752    
10753                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10754                            }
10755    
10756                            if (orderByComparator != null) {
10757                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10758                                            orderByComparator);
10759                            }
10760                            else
10761                             if (pagination) {
10762                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10763                            }
10764    
10765                            String sql = query.toString();
10766    
10767                            Session session = null;
10768    
10769                            try {
10770                                    session = openSession();
10771    
10772                                    Query q = session.createQuery(sql);
10773    
10774                                    QueryPos qPos = QueryPos.getInstance(q);
10775    
10776                                    qPos.add(groupId);
10777    
10778                                    if (bindStructureId) {
10779                                            qPos.add(structureId);
10780                                    }
10781    
10782                                    if (!pagination) {
10783                                            list = (List<JournalArticle>)QueryUtil.list(q,
10784                                                            getDialect(), start, end, false);
10785    
10786                                            Collections.sort(list);
10787    
10788                                            list = new UnmodifiableList<JournalArticle>(list);
10789                                    }
10790                                    else {
10791                                            list = (List<JournalArticle>)QueryUtil.list(q,
10792                                                            getDialect(), start, end);
10793                                    }
10794    
10795                                    cacheResult(list);
10796    
10797                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10798                            }
10799                            catch (Exception e) {
10800                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10801    
10802                                    throw processException(e);
10803                            }
10804                            finally {
10805                                    closeSession(session);
10806                            }
10807                    }
10808    
10809                    return list;
10810            }
10811    
10812            /**
10813             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10814             *
10815             * @param groupId the group ID
10816             * @param structureId the structure ID
10817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10818             * @return the first matching journal article
10819             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10820             * @throws SystemException if a system exception occurred
10821             */
10822            @Override
10823            public JournalArticle findByG_S_First(long groupId, String structureId,
10824                    OrderByComparator orderByComparator)
10825                    throws NoSuchArticleException, SystemException {
10826                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
10827                                    orderByComparator);
10828    
10829                    if (journalArticle != null) {
10830                            return journalArticle;
10831                    }
10832    
10833                    StringBundler msg = new StringBundler(6);
10834    
10835                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10836    
10837                    msg.append("groupId=");
10838                    msg.append(groupId);
10839    
10840                    msg.append(", structureId=");
10841                    msg.append(structureId);
10842    
10843                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10844    
10845                    throw new NoSuchArticleException(msg.toString());
10846            }
10847    
10848            /**
10849             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10850             *
10851             * @param groupId the group ID
10852             * @param structureId the structure ID
10853             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10854             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10855             * @throws SystemException if a system exception occurred
10856             */
10857            @Override
10858            public JournalArticle fetchByG_S_First(long groupId, String structureId,
10859                    OrderByComparator orderByComparator) throws SystemException {
10860                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
10861                                    orderByComparator);
10862    
10863                    if (!list.isEmpty()) {
10864                            return list.get(0);
10865                    }
10866    
10867                    return null;
10868            }
10869    
10870            /**
10871             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10872             *
10873             * @param groupId the group ID
10874             * @param structureId the structure ID
10875             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10876             * @return the last matching journal article
10877             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10878             * @throws SystemException if a system exception occurred
10879             */
10880            @Override
10881            public JournalArticle findByG_S_Last(long groupId, String structureId,
10882                    OrderByComparator orderByComparator)
10883                    throws NoSuchArticleException, SystemException {
10884                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
10885                                    orderByComparator);
10886    
10887                    if (journalArticle != null) {
10888                            return journalArticle;
10889                    }
10890    
10891                    StringBundler msg = new StringBundler(6);
10892    
10893                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10894    
10895                    msg.append("groupId=");
10896                    msg.append(groupId);
10897    
10898                    msg.append(", structureId=");
10899                    msg.append(structureId);
10900    
10901                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10902    
10903                    throw new NoSuchArticleException(msg.toString());
10904            }
10905    
10906            /**
10907             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10908             *
10909             * @param groupId the group ID
10910             * @param structureId the structure ID
10911             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10912             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10913             * @throws SystemException if a system exception occurred
10914             */
10915            @Override
10916            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
10917                    OrderByComparator orderByComparator) throws SystemException {
10918                    int count = countByG_S(groupId, structureId);
10919    
10920                    if (count == 0) {
10921                            return null;
10922                    }
10923    
10924                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
10925                                    count, orderByComparator);
10926    
10927                    if (!list.isEmpty()) {
10928                            return list.get(0);
10929                    }
10930    
10931                    return null;
10932            }
10933    
10934            /**
10935             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10936             *
10937             * @param id the primary key of the current journal article
10938             * @param groupId the group ID
10939             * @param structureId the structure ID
10940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10941             * @return the previous, current, and next journal article
10942             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10943             * @throws SystemException if a system exception occurred
10944             */
10945            @Override
10946            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
10947                    String structureId, OrderByComparator orderByComparator)
10948                    throws NoSuchArticleException, SystemException {
10949                    JournalArticle journalArticle = findByPrimaryKey(id);
10950    
10951                    Session session = null;
10952    
10953                    try {
10954                            session = openSession();
10955    
10956                            JournalArticle[] array = new JournalArticleImpl[3];
10957    
10958                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10959                                            structureId, orderByComparator, true);
10960    
10961                            array[1] = journalArticle;
10962    
10963                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10964                                            structureId, orderByComparator, false);
10965    
10966                            return array;
10967                    }
10968                    catch (Exception e) {
10969                            throw processException(e);
10970                    }
10971                    finally {
10972                            closeSession(session);
10973                    }
10974            }
10975    
10976            protected JournalArticle getByG_S_PrevAndNext(Session session,
10977                    JournalArticle journalArticle, long groupId, String structureId,
10978                    OrderByComparator orderByComparator, boolean previous) {
10979                    StringBundler query = null;
10980    
10981                    if (orderByComparator != null) {
10982                            query = new StringBundler(6 +
10983                                            (orderByComparator.getOrderByFields().length * 6));
10984                    }
10985                    else {
10986                            query = new StringBundler(3);
10987                    }
10988    
10989                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10990    
10991                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10992    
10993                    boolean bindStructureId = false;
10994    
10995                    if (structureId == null) {
10996                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10997                    }
10998                    else if (structureId.equals(StringPool.BLANK)) {
10999                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11000                    }
11001                    else {
11002                            bindStructureId = true;
11003    
11004                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11005                    }
11006    
11007                    if (orderByComparator != null) {
11008                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11009    
11010                            if (orderByConditionFields.length > 0) {
11011                                    query.append(WHERE_AND);
11012                            }
11013    
11014                            for (int i = 0; i < orderByConditionFields.length; i++) {
11015                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11016                                    query.append(orderByConditionFields[i]);
11017    
11018                                    if ((i + 1) < orderByConditionFields.length) {
11019                                            if (orderByComparator.isAscending() ^ previous) {
11020                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11021                                            }
11022                                            else {
11023                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11024                                            }
11025                                    }
11026                                    else {
11027                                            if (orderByComparator.isAscending() ^ previous) {
11028                                                    query.append(WHERE_GREATER_THAN);
11029                                            }
11030                                            else {
11031                                                    query.append(WHERE_LESSER_THAN);
11032                                            }
11033                                    }
11034                            }
11035    
11036                            query.append(ORDER_BY_CLAUSE);
11037    
11038                            String[] orderByFields = orderByComparator.getOrderByFields();
11039    
11040                            for (int i = 0; i < orderByFields.length; i++) {
11041                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11042                                    query.append(orderByFields[i]);
11043    
11044                                    if ((i + 1) < orderByFields.length) {
11045                                            if (orderByComparator.isAscending() ^ previous) {
11046                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11047                                            }
11048                                            else {
11049                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11050                                            }
11051                                    }
11052                                    else {
11053                                            if (orderByComparator.isAscending() ^ previous) {
11054                                                    query.append(ORDER_BY_ASC);
11055                                            }
11056                                            else {
11057                                                    query.append(ORDER_BY_DESC);
11058                                            }
11059                                    }
11060                            }
11061                    }
11062                    else {
11063                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11064                    }
11065    
11066                    String sql = query.toString();
11067    
11068                    Query q = session.createQuery(sql);
11069    
11070                    q.setFirstResult(0);
11071                    q.setMaxResults(2);
11072    
11073                    QueryPos qPos = QueryPos.getInstance(q);
11074    
11075                    qPos.add(groupId);
11076    
11077                    if (bindStructureId) {
11078                            qPos.add(structureId);
11079                    }
11080    
11081                    if (orderByComparator != null) {
11082                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11083    
11084                            for (Object value : values) {
11085                                    qPos.add(value);
11086                            }
11087                    }
11088    
11089                    List<JournalArticle> list = q.list();
11090    
11091                    if (list.size() == 2) {
11092                            return list.get(1);
11093                    }
11094                    else {
11095                            return null;
11096                    }
11097            }
11098    
11099            /**
11100             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11101             *
11102             * @param groupId the group ID
11103             * @param structureId the structure ID
11104             * @return the matching journal articles that the user has permission to view
11105             * @throws SystemException if a system exception occurred
11106             */
11107            @Override
11108            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
11109                    throws SystemException {
11110                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
11111                            QueryUtil.ALL_POS, null);
11112            }
11113    
11114            /**
11115             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11116             *
11117             * <p>
11118             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11119             * </p>
11120             *
11121             * @param groupId the group ID
11122             * @param structureId the structure ID
11123             * @param start the lower bound of the range of journal articles
11124             * @param end the upper bound of the range of journal articles (not inclusive)
11125             * @return the range of matching journal articles that the user has permission to view
11126             * @throws SystemException if a system exception occurred
11127             */
11128            @Override
11129            public List<JournalArticle> filterFindByG_S(long groupId,
11130                    String structureId, int start, int end) throws SystemException {
11131                    return filterFindByG_S(groupId, structureId, start, end, null);
11132            }
11133    
11134            /**
11135             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
11136             *
11137             * <p>
11138             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11139             * </p>
11140             *
11141             * @param groupId the group ID
11142             * @param structureId the structure ID
11143             * @param start the lower bound of the range of journal articles
11144             * @param end the upper bound of the range of journal articles (not inclusive)
11145             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11146             * @return the ordered range of matching journal articles that the user has permission to view
11147             * @throws SystemException if a system exception occurred
11148             */
11149            @Override
11150            public List<JournalArticle> filterFindByG_S(long groupId,
11151                    String structureId, int start, int end,
11152                    OrderByComparator orderByComparator) throws SystemException {
11153                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11154                            return findByG_S(groupId, structureId, start, end, orderByComparator);
11155                    }
11156    
11157                    StringBundler query = null;
11158    
11159                    if (orderByComparator != null) {
11160                            query = new StringBundler(4 +
11161                                            (orderByComparator.getOrderByFields().length * 3));
11162                    }
11163                    else {
11164                            query = new StringBundler(4);
11165                    }
11166    
11167                    if (getDB().isSupportsInlineDistinct()) {
11168                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11169                    }
11170                    else {
11171                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11172                    }
11173    
11174                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11175    
11176                    boolean bindStructureId = false;
11177    
11178                    if (structureId == null) {
11179                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11180                    }
11181                    else if (structureId.equals(StringPool.BLANK)) {
11182                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11183                    }
11184                    else {
11185                            bindStructureId = true;
11186    
11187                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11188                    }
11189    
11190                    if (!getDB().isSupportsInlineDistinct()) {
11191                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11192                    }
11193    
11194                    if (orderByComparator != null) {
11195                            if (getDB().isSupportsInlineDistinct()) {
11196                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11197                                            orderByComparator, true);
11198                            }
11199                            else {
11200                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11201                                            orderByComparator, true);
11202                            }
11203                    }
11204                    else {
11205                            if (getDB().isSupportsInlineDistinct()) {
11206                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11207                            }
11208                            else {
11209                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11210                            }
11211                    }
11212    
11213                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11214                                    JournalArticle.class.getName(),
11215                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11216    
11217                    Session session = null;
11218    
11219                    try {
11220                            session = openSession();
11221    
11222                            SQLQuery q = session.createSQLQuery(sql);
11223    
11224                            if (getDB().isSupportsInlineDistinct()) {
11225                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11226                            }
11227                            else {
11228                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11229                            }
11230    
11231                            QueryPos qPos = QueryPos.getInstance(q);
11232    
11233                            qPos.add(groupId);
11234    
11235                            if (bindStructureId) {
11236                                    qPos.add(structureId);
11237                            }
11238    
11239                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11240                                    end);
11241                    }
11242                    catch (Exception e) {
11243                            throw processException(e);
11244                    }
11245                    finally {
11246                            closeSession(session);
11247                    }
11248            }
11249    
11250            /**
11251             * 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;.
11252             *
11253             * @param id the primary key of the current journal article
11254             * @param groupId the group ID
11255             * @param structureId the structure ID
11256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11257             * @return the previous, current, and next journal article
11258             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11259             * @throws SystemException if a system exception occurred
11260             */
11261            @Override
11262            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
11263                    String structureId, OrderByComparator orderByComparator)
11264                    throws NoSuchArticleException, SystemException {
11265                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11266                            return findByG_S_PrevAndNext(id, groupId, structureId,
11267                                    orderByComparator);
11268                    }
11269    
11270                    JournalArticle journalArticle = findByPrimaryKey(id);
11271    
11272                    Session session = null;
11273    
11274                    try {
11275                            session = openSession();
11276    
11277                            JournalArticle[] array = new JournalArticleImpl[3];
11278    
11279                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
11280                                            groupId, structureId, orderByComparator, true);
11281    
11282                            array[1] = journalArticle;
11283    
11284                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
11285                                            groupId, structureId, orderByComparator, false);
11286    
11287                            return array;
11288                    }
11289                    catch (Exception e) {
11290                            throw processException(e);
11291                    }
11292                    finally {
11293                            closeSession(session);
11294                    }
11295            }
11296    
11297            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
11298                    JournalArticle journalArticle, long groupId, String structureId,
11299                    OrderByComparator orderByComparator, boolean previous) {
11300                    StringBundler query = null;
11301    
11302                    if (orderByComparator != null) {
11303                            query = new StringBundler(6 +
11304                                            (orderByComparator.getOrderByFields().length * 6));
11305                    }
11306                    else {
11307                            query = new StringBundler(3);
11308                    }
11309    
11310                    if (getDB().isSupportsInlineDistinct()) {
11311                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11312                    }
11313                    else {
11314                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11315                    }
11316    
11317                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11318    
11319                    boolean bindStructureId = false;
11320    
11321                    if (structureId == null) {
11322                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11323                    }
11324                    else if (structureId.equals(StringPool.BLANK)) {
11325                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11326                    }
11327                    else {
11328                            bindStructureId = true;
11329    
11330                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11331                    }
11332    
11333                    if (!getDB().isSupportsInlineDistinct()) {
11334                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11335                    }
11336    
11337                    if (orderByComparator != null) {
11338                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11339    
11340                            if (orderByConditionFields.length > 0) {
11341                                    query.append(WHERE_AND);
11342                            }
11343    
11344                            for (int i = 0; i < orderByConditionFields.length; i++) {
11345                                    if (getDB().isSupportsInlineDistinct()) {
11346                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11347                                    }
11348                                    else {
11349                                            query.append(_ORDER_BY_ENTITY_TABLE);
11350                                    }
11351    
11352                                    query.append(orderByConditionFields[i]);
11353    
11354                                    if ((i + 1) < orderByConditionFields.length) {
11355                                            if (orderByComparator.isAscending() ^ previous) {
11356                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11357                                            }
11358                                            else {
11359                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11360                                            }
11361                                    }
11362                                    else {
11363                                            if (orderByComparator.isAscending() ^ previous) {
11364                                                    query.append(WHERE_GREATER_THAN);
11365                                            }
11366                                            else {
11367                                                    query.append(WHERE_LESSER_THAN);
11368                                            }
11369                                    }
11370                            }
11371    
11372                            query.append(ORDER_BY_CLAUSE);
11373    
11374                            String[] orderByFields = orderByComparator.getOrderByFields();
11375    
11376                            for (int i = 0; i < orderByFields.length; i++) {
11377                                    if (getDB().isSupportsInlineDistinct()) {
11378                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11379                                    }
11380                                    else {
11381                                            query.append(_ORDER_BY_ENTITY_TABLE);
11382                                    }
11383    
11384                                    query.append(orderByFields[i]);
11385    
11386                                    if ((i + 1) < orderByFields.length) {
11387                                            if (orderByComparator.isAscending() ^ previous) {
11388                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11389                                            }
11390                                            else {
11391                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11392                                            }
11393                                    }
11394                                    else {
11395                                            if (orderByComparator.isAscending() ^ previous) {
11396                                                    query.append(ORDER_BY_ASC);
11397                                            }
11398                                            else {
11399                                                    query.append(ORDER_BY_DESC);
11400                                            }
11401                                    }
11402                            }
11403                    }
11404                    else {
11405                            if (getDB().isSupportsInlineDistinct()) {
11406                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11407                            }
11408                            else {
11409                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11410                            }
11411                    }
11412    
11413                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11414                                    JournalArticle.class.getName(),
11415                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11416    
11417                    SQLQuery q = session.createSQLQuery(sql);
11418    
11419                    q.setFirstResult(0);
11420                    q.setMaxResults(2);
11421    
11422                    if (getDB().isSupportsInlineDistinct()) {
11423                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11424                    }
11425                    else {
11426                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11427                    }
11428    
11429                    QueryPos qPos = QueryPos.getInstance(q);
11430    
11431                    qPos.add(groupId);
11432    
11433                    if (bindStructureId) {
11434                            qPos.add(structureId);
11435                    }
11436    
11437                    if (orderByComparator != null) {
11438                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11439    
11440                            for (Object value : values) {
11441                                    qPos.add(value);
11442                            }
11443                    }
11444    
11445                    List<JournalArticle> list = q.list();
11446    
11447                    if (list.size() == 2) {
11448                            return list.get(1);
11449                    }
11450                    else {
11451                            return null;
11452                    }
11453            }
11454    
11455            /**
11456             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
11457             *
11458             * @param groupId the group ID
11459             * @param structureId the structure ID
11460             * @throws SystemException if a system exception occurred
11461             */
11462            @Override
11463            public void removeByG_S(long groupId, String structureId)
11464                    throws SystemException {
11465                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
11466                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11467                            remove(journalArticle);
11468                    }
11469            }
11470    
11471            /**
11472             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
11473             *
11474             * @param groupId the group ID
11475             * @param structureId the structure ID
11476             * @return the number of matching journal articles
11477             * @throws SystemException if a system exception occurred
11478             */
11479            @Override
11480            public int countByG_S(long groupId, String structureId)
11481                    throws SystemException {
11482                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
11483    
11484                    Object[] finderArgs = new Object[] { groupId, structureId };
11485    
11486                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11487                                    this);
11488    
11489                    if (count == null) {
11490                            StringBundler query = new StringBundler(3);
11491    
11492                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11493    
11494                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11495    
11496                            boolean bindStructureId = false;
11497    
11498                            if (structureId == null) {
11499                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11500                            }
11501                            else if (structureId.equals(StringPool.BLANK)) {
11502                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11503                            }
11504                            else {
11505                                    bindStructureId = true;
11506    
11507                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11508                            }
11509    
11510                            String sql = query.toString();
11511    
11512                            Session session = null;
11513    
11514                            try {
11515                                    session = openSession();
11516    
11517                                    Query q = session.createQuery(sql);
11518    
11519                                    QueryPos qPos = QueryPos.getInstance(q);
11520    
11521                                    qPos.add(groupId);
11522    
11523                                    if (bindStructureId) {
11524                                            qPos.add(structureId);
11525                                    }
11526    
11527                                    count = (Long)q.uniqueResult();
11528    
11529                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11530                            }
11531                            catch (Exception e) {
11532                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11533    
11534                                    throw processException(e);
11535                            }
11536                            finally {
11537                                    closeSession(session);
11538                            }
11539                    }
11540    
11541                    return count.intValue();
11542            }
11543    
11544            /**
11545             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11546             *
11547             * @param groupId the group ID
11548             * @param structureId the structure ID
11549             * @return the number of matching journal articles that the user has permission to view
11550             * @throws SystemException if a system exception occurred
11551             */
11552            @Override
11553            public int filterCountByG_S(long groupId, String structureId)
11554                    throws SystemException {
11555                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11556                            return countByG_S(groupId, structureId);
11557                    }
11558    
11559                    StringBundler query = new StringBundler(3);
11560    
11561                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11562    
11563                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11564    
11565                    boolean bindStructureId = false;
11566    
11567                    if (structureId == null) {
11568                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11569                    }
11570                    else if (structureId.equals(StringPool.BLANK)) {
11571                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11572                    }
11573                    else {
11574                            bindStructureId = true;
11575    
11576                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11577                    }
11578    
11579                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11580                                    JournalArticle.class.getName(),
11581                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11582    
11583                    Session session = null;
11584    
11585                    try {
11586                            session = openSession();
11587    
11588                            SQLQuery q = session.createSQLQuery(sql);
11589    
11590                            q.addScalar(COUNT_COLUMN_NAME,
11591                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11592    
11593                            QueryPos qPos = QueryPos.getInstance(q);
11594    
11595                            qPos.add(groupId);
11596    
11597                            if (bindStructureId) {
11598                                    qPos.add(structureId);
11599                            }
11600    
11601                            Long count = (Long)q.uniqueResult();
11602    
11603                            return count.intValue();
11604                    }
11605                    catch (Exception e) {
11606                            throw processException(e);
11607                    }
11608                    finally {
11609                            closeSession(session);
11610                    }
11611            }
11612    
11613            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
11614            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
11615            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
11616            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
11617            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11618                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11619                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11620                            "findByG_T",
11621                            new String[] {
11622                                    Long.class.getName(), String.class.getName(),
11623                                    
11624                            Integer.class.getName(), Integer.class.getName(),
11625                                    OrderByComparator.class.getName()
11626                            });
11627            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11628                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11629                            JournalArticleImpl.class,
11630                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
11631                            new String[] { Long.class.getName(), String.class.getName() },
11632                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11633                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
11634                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11635                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11636            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11637                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11638                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
11639                            new String[] { Long.class.getName(), String.class.getName() });
11640    
11641            /**
11642             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
11643             *
11644             * @param groupId the group ID
11645             * @param templateId the template ID
11646             * @return the matching journal articles
11647             * @throws SystemException if a system exception occurred
11648             */
11649            @Override
11650            public List<JournalArticle> findByG_T(long groupId, String templateId)
11651                    throws SystemException {
11652                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
11653                            QueryUtil.ALL_POS, null);
11654            }
11655    
11656            /**
11657             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
11658             *
11659             * <p>
11660             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11661             * </p>
11662             *
11663             * @param groupId the group ID
11664             * @param templateId the template ID
11665             * @param start the lower bound of the range of journal articles
11666             * @param end the upper bound of the range of journal articles (not inclusive)
11667             * @return the range of matching journal articles
11668             * @throws SystemException if a system exception occurred
11669             */
11670            @Override
11671            public List<JournalArticle> findByG_T(long groupId, String templateId,
11672                    int start, int end) throws SystemException {
11673                    return findByG_T(groupId, templateId, start, end, null);
11674            }
11675    
11676            /**
11677             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
11678             *
11679             * <p>
11680             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11681             * </p>
11682             *
11683             * @param groupId the group ID
11684             * @param templateId the template ID
11685             * @param start the lower bound of the range of journal articles
11686             * @param end the upper bound of the range of journal articles (not inclusive)
11687             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11688             * @return the ordered range of matching journal articles
11689             * @throws SystemException if a system exception occurred
11690             */
11691            @Override
11692            public List<JournalArticle> findByG_T(long groupId, String templateId,
11693                    int start, int end, OrderByComparator orderByComparator)
11694                    throws SystemException {
11695                    boolean pagination = true;
11696                    FinderPath finderPath = null;
11697                    Object[] finderArgs = null;
11698    
11699                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11700                                    (orderByComparator == null)) {
11701                            pagination = false;
11702                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
11703                            finderArgs = new Object[] { groupId, templateId };
11704                    }
11705                    else {
11706                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
11707                            finderArgs = new Object[] {
11708                                            groupId, templateId,
11709                                            
11710                                            start, end, orderByComparator
11711                                    };
11712                    }
11713    
11714                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11715                                    finderArgs, this);
11716    
11717                    if ((list != null) && !list.isEmpty()) {
11718                            for (JournalArticle journalArticle : list) {
11719                                    if ((groupId != journalArticle.getGroupId()) ||
11720                                                    !Validator.equals(templateId,
11721                                                            journalArticle.getTemplateId())) {
11722                                            list = null;
11723    
11724                                            break;
11725                                    }
11726                            }
11727                    }
11728    
11729                    if (list == null) {
11730                            StringBundler query = null;
11731    
11732                            if (orderByComparator != null) {
11733                                    query = new StringBundler(4 +
11734                                                    (orderByComparator.getOrderByFields().length * 3));
11735                            }
11736                            else {
11737                                    query = new StringBundler(4);
11738                            }
11739    
11740                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11741    
11742                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11743    
11744                            boolean bindTemplateId = false;
11745    
11746                            if (templateId == null) {
11747                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11748                            }
11749                            else if (templateId.equals(StringPool.BLANK)) {
11750                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11751                            }
11752                            else {
11753                                    bindTemplateId = true;
11754    
11755                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11756                            }
11757    
11758                            if (orderByComparator != null) {
11759                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11760                                            orderByComparator);
11761                            }
11762                            else
11763                             if (pagination) {
11764                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11765                            }
11766    
11767                            String sql = query.toString();
11768    
11769                            Session session = null;
11770    
11771                            try {
11772                                    session = openSession();
11773    
11774                                    Query q = session.createQuery(sql);
11775    
11776                                    QueryPos qPos = QueryPos.getInstance(q);
11777    
11778                                    qPos.add(groupId);
11779    
11780                                    if (bindTemplateId) {
11781                                            qPos.add(templateId);
11782                                    }
11783    
11784                                    if (!pagination) {
11785                                            list = (List<JournalArticle>)QueryUtil.list(q,
11786                                                            getDialect(), start, end, false);
11787    
11788                                            Collections.sort(list);
11789    
11790                                            list = new UnmodifiableList<JournalArticle>(list);
11791                                    }
11792                                    else {
11793                                            list = (List<JournalArticle>)QueryUtil.list(q,
11794                                                            getDialect(), start, end);
11795                                    }
11796    
11797                                    cacheResult(list);
11798    
11799                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11800                            }
11801                            catch (Exception e) {
11802                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11803    
11804                                    throw processException(e);
11805                            }
11806                            finally {
11807                                    closeSession(session);
11808                            }
11809                    }
11810    
11811                    return list;
11812            }
11813    
11814            /**
11815             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11816             *
11817             * @param groupId the group ID
11818             * @param templateId the template ID
11819             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11820             * @return the first matching journal article
11821             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11822             * @throws SystemException if a system exception occurred
11823             */
11824            @Override
11825            public JournalArticle findByG_T_First(long groupId, String templateId,
11826                    OrderByComparator orderByComparator)
11827                    throws NoSuchArticleException, SystemException {
11828                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
11829                                    orderByComparator);
11830    
11831                    if (journalArticle != null) {
11832                            return journalArticle;
11833                    }
11834    
11835                    StringBundler msg = new StringBundler(6);
11836    
11837                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11838    
11839                    msg.append("groupId=");
11840                    msg.append(groupId);
11841    
11842                    msg.append(", templateId=");
11843                    msg.append(templateId);
11844    
11845                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11846    
11847                    throw new NoSuchArticleException(msg.toString());
11848            }
11849    
11850            /**
11851             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11852             *
11853             * @param groupId the group ID
11854             * @param templateId the template ID
11855             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11856             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11857             * @throws SystemException if a system exception occurred
11858             */
11859            @Override
11860            public JournalArticle fetchByG_T_First(long groupId, String templateId,
11861                    OrderByComparator orderByComparator) throws SystemException {
11862                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
11863                                    orderByComparator);
11864    
11865                    if (!list.isEmpty()) {
11866                            return list.get(0);
11867                    }
11868    
11869                    return null;
11870            }
11871    
11872            /**
11873             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11874             *
11875             * @param groupId the group ID
11876             * @param templateId the template ID
11877             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11878             * @return the last matching journal article
11879             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11880             * @throws SystemException if a system exception occurred
11881             */
11882            @Override
11883            public JournalArticle findByG_T_Last(long groupId, String templateId,
11884                    OrderByComparator orderByComparator)
11885                    throws NoSuchArticleException, SystemException {
11886                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
11887                                    orderByComparator);
11888    
11889                    if (journalArticle != null) {
11890                            return journalArticle;
11891                    }
11892    
11893                    StringBundler msg = new StringBundler(6);
11894    
11895                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11896    
11897                    msg.append("groupId=");
11898                    msg.append(groupId);
11899    
11900                    msg.append(", templateId=");
11901                    msg.append(templateId);
11902    
11903                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11904    
11905                    throw new NoSuchArticleException(msg.toString());
11906            }
11907    
11908            /**
11909             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11910             *
11911             * @param groupId the group ID
11912             * @param templateId the template ID
11913             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11914             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11915             * @throws SystemException if a system exception occurred
11916             */
11917            @Override
11918            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
11919                    OrderByComparator orderByComparator) throws SystemException {
11920                    int count = countByG_T(groupId, templateId);
11921    
11922                    if (count == 0) {
11923                            return null;
11924                    }
11925    
11926                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
11927                                    count, orderByComparator);
11928    
11929                    if (!list.isEmpty()) {
11930                            return list.get(0);
11931                    }
11932    
11933                    return null;
11934            }
11935    
11936            /**
11937             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11938             *
11939             * @param id the primary key of the current journal article
11940             * @param groupId the group ID
11941             * @param templateId the template ID
11942             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11943             * @return the previous, current, and next journal article
11944             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11945             * @throws SystemException if a system exception occurred
11946             */
11947            @Override
11948            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
11949                    String templateId, OrderByComparator orderByComparator)
11950                    throws NoSuchArticleException, SystemException {
11951                    JournalArticle journalArticle = findByPrimaryKey(id);
11952    
11953                    Session session = null;
11954    
11955                    try {
11956                            session = openSession();
11957    
11958                            JournalArticle[] array = new JournalArticleImpl[3];
11959    
11960                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11961                                            templateId, orderByComparator, true);
11962    
11963                            array[1] = journalArticle;
11964    
11965                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11966                                            templateId, orderByComparator, false);
11967    
11968                            return array;
11969                    }
11970                    catch (Exception e) {
11971                            throw processException(e);
11972                    }
11973                    finally {
11974                            closeSession(session);
11975                    }
11976            }
11977    
11978            protected JournalArticle getByG_T_PrevAndNext(Session session,
11979                    JournalArticle journalArticle, long groupId, String templateId,
11980                    OrderByComparator orderByComparator, boolean previous) {
11981                    StringBundler query = null;
11982    
11983                    if (orderByComparator != null) {
11984                            query = new StringBundler(6 +
11985                                            (orderByComparator.getOrderByFields().length * 6));
11986                    }
11987                    else {
11988                            query = new StringBundler(3);
11989                    }
11990    
11991                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11992    
11993                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11994    
11995                    boolean bindTemplateId = false;
11996    
11997                    if (templateId == null) {
11998                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11999                    }
12000                    else if (templateId.equals(StringPool.BLANK)) {
12001                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12002                    }
12003                    else {
12004                            bindTemplateId = true;
12005    
12006                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12007                    }
12008    
12009                    if (orderByComparator != null) {
12010                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12011    
12012                            if (orderByConditionFields.length > 0) {
12013                                    query.append(WHERE_AND);
12014                            }
12015    
12016                            for (int i = 0; i < orderByConditionFields.length; i++) {
12017                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12018                                    query.append(orderByConditionFields[i]);
12019    
12020                                    if ((i + 1) < orderByConditionFields.length) {
12021                                            if (orderByComparator.isAscending() ^ previous) {
12022                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12023                                            }
12024                                            else {
12025                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12026                                            }
12027                                    }
12028                                    else {
12029                                            if (orderByComparator.isAscending() ^ previous) {
12030                                                    query.append(WHERE_GREATER_THAN);
12031                                            }
12032                                            else {
12033                                                    query.append(WHERE_LESSER_THAN);
12034                                            }
12035                                    }
12036                            }
12037    
12038                            query.append(ORDER_BY_CLAUSE);
12039    
12040                            String[] orderByFields = orderByComparator.getOrderByFields();
12041    
12042                            for (int i = 0; i < orderByFields.length; i++) {
12043                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12044                                    query.append(orderByFields[i]);
12045    
12046                                    if ((i + 1) < orderByFields.length) {
12047                                            if (orderByComparator.isAscending() ^ previous) {
12048                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12049                                            }
12050                                            else {
12051                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12052                                            }
12053                                    }
12054                                    else {
12055                                            if (orderByComparator.isAscending() ^ previous) {
12056                                                    query.append(ORDER_BY_ASC);
12057                                            }
12058                                            else {
12059                                                    query.append(ORDER_BY_DESC);
12060                                            }
12061                                    }
12062                            }
12063                    }
12064                    else {
12065                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12066                    }
12067    
12068                    String sql = query.toString();
12069    
12070                    Query q = session.createQuery(sql);
12071    
12072                    q.setFirstResult(0);
12073                    q.setMaxResults(2);
12074    
12075                    QueryPos qPos = QueryPos.getInstance(q);
12076    
12077                    qPos.add(groupId);
12078    
12079                    if (bindTemplateId) {
12080                            qPos.add(templateId);
12081                    }
12082    
12083                    if (orderByComparator != null) {
12084                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12085    
12086                            for (Object value : values) {
12087                                    qPos.add(value);
12088                            }
12089                    }
12090    
12091                    List<JournalArticle> list = q.list();
12092    
12093                    if (list.size() == 2) {
12094                            return list.get(1);
12095                    }
12096                    else {
12097                            return null;
12098                    }
12099            }
12100    
12101            /**
12102             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12103             *
12104             * @param groupId the group ID
12105             * @param templateId the template ID
12106             * @return the matching journal articles that the user has permission to view
12107             * @throws SystemException if a system exception occurred
12108             */
12109            @Override
12110            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
12111                    throws SystemException {
12112                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
12113                            QueryUtil.ALL_POS, null);
12114            }
12115    
12116            /**
12117             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12118             *
12119             * <p>
12120             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12121             * </p>
12122             *
12123             * @param groupId the group ID
12124             * @param templateId the template ID
12125             * @param start the lower bound of the range of journal articles
12126             * @param end the upper bound of the range of journal articles (not inclusive)
12127             * @return the range of matching journal articles that the user has permission to view
12128             * @throws SystemException if a system exception occurred
12129             */
12130            @Override
12131            public List<JournalArticle> filterFindByG_T(long groupId,
12132                    String templateId, int start, int end) throws SystemException {
12133                    return filterFindByG_T(groupId, templateId, start, end, null);
12134            }
12135    
12136            /**
12137             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
12138             *
12139             * <p>
12140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12141             * </p>
12142             *
12143             * @param groupId the group ID
12144             * @param templateId the template ID
12145             * @param start the lower bound of the range of journal articles
12146             * @param end the upper bound of the range of journal articles (not inclusive)
12147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12148             * @return the ordered range of matching journal articles that the user has permission to view
12149             * @throws SystemException if a system exception occurred
12150             */
12151            @Override
12152            public List<JournalArticle> filterFindByG_T(long groupId,
12153                    String templateId, int start, int end,
12154                    OrderByComparator orderByComparator) throws SystemException {
12155                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12156                            return findByG_T(groupId, templateId, start, end, orderByComparator);
12157                    }
12158    
12159                    StringBundler query = null;
12160    
12161                    if (orderByComparator != null) {
12162                            query = new StringBundler(4 +
12163                                            (orderByComparator.getOrderByFields().length * 3));
12164                    }
12165                    else {
12166                            query = new StringBundler(4);
12167                    }
12168    
12169                    if (getDB().isSupportsInlineDistinct()) {
12170                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12171                    }
12172                    else {
12173                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12174                    }
12175    
12176                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12177    
12178                    boolean bindTemplateId = false;
12179    
12180                    if (templateId == null) {
12181                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12182                    }
12183                    else if (templateId.equals(StringPool.BLANK)) {
12184                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12185                    }
12186                    else {
12187                            bindTemplateId = true;
12188    
12189                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12190                    }
12191    
12192                    if (!getDB().isSupportsInlineDistinct()) {
12193                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12194                    }
12195    
12196                    if (orderByComparator != null) {
12197                            if (getDB().isSupportsInlineDistinct()) {
12198                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12199                                            orderByComparator, true);
12200                            }
12201                            else {
12202                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12203                                            orderByComparator, true);
12204                            }
12205                    }
12206                    else {
12207                            if (getDB().isSupportsInlineDistinct()) {
12208                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12209                            }
12210                            else {
12211                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12212                            }
12213                    }
12214    
12215                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12216                                    JournalArticle.class.getName(),
12217                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12218    
12219                    Session session = null;
12220    
12221                    try {
12222                            session = openSession();
12223    
12224                            SQLQuery q = session.createSQLQuery(sql);
12225    
12226                            if (getDB().isSupportsInlineDistinct()) {
12227                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12228                            }
12229                            else {
12230                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12231                            }
12232    
12233                            QueryPos qPos = QueryPos.getInstance(q);
12234    
12235                            qPos.add(groupId);
12236    
12237                            if (bindTemplateId) {
12238                                    qPos.add(templateId);
12239                            }
12240    
12241                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12242                                    end);
12243                    }
12244                    catch (Exception e) {
12245                            throw processException(e);
12246                    }
12247                    finally {
12248                            closeSession(session);
12249                    }
12250            }
12251    
12252            /**
12253             * 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;.
12254             *
12255             * @param id the primary key of the current journal article
12256             * @param groupId the group ID
12257             * @param templateId the template ID
12258             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12259             * @return the previous, current, and next journal article
12260             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12261             * @throws SystemException if a system exception occurred
12262             */
12263            @Override
12264            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
12265                    String templateId, OrderByComparator orderByComparator)
12266                    throws NoSuchArticleException, SystemException {
12267                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12268                            return findByG_T_PrevAndNext(id, groupId, templateId,
12269                                    orderByComparator);
12270                    }
12271    
12272                    JournalArticle journalArticle = findByPrimaryKey(id);
12273    
12274                    Session session = null;
12275    
12276                    try {
12277                            session = openSession();
12278    
12279                            JournalArticle[] array = new JournalArticleImpl[3];
12280    
12281                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
12282                                            groupId, templateId, orderByComparator, true);
12283    
12284                            array[1] = journalArticle;
12285    
12286                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
12287                                            groupId, templateId, orderByComparator, false);
12288    
12289                            return array;
12290                    }
12291                    catch (Exception e) {
12292                            throw processException(e);
12293                    }
12294                    finally {
12295                            closeSession(session);
12296                    }
12297            }
12298    
12299            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
12300                    JournalArticle journalArticle, long groupId, String templateId,
12301                    OrderByComparator orderByComparator, boolean previous) {
12302                    StringBundler query = null;
12303    
12304                    if (orderByComparator != null) {
12305                            query = new StringBundler(6 +
12306                                            (orderByComparator.getOrderByFields().length * 6));
12307                    }
12308                    else {
12309                            query = new StringBundler(3);
12310                    }
12311    
12312                    if (getDB().isSupportsInlineDistinct()) {
12313                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12314                    }
12315                    else {
12316                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12317                    }
12318    
12319                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12320    
12321                    boolean bindTemplateId = false;
12322    
12323                    if (templateId == null) {
12324                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12325                    }
12326                    else if (templateId.equals(StringPool.BLANK)) {
12327                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12328                    }
12329                    else {
12330                            bindTemplateId = true;
12331    
12332                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12333                    }
12334    
12335                    if (!getDB().isSupportsInlineDistinct()) {
12336                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12337                    }
12338    
12339                    if (orderByComparator != null) {
12340                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12341    
12342                            if (orderByConditionFields.length > 0) {
12343                                    query.append(WHERE_AND);
12344                            }
12345    
12346                            for (int i = 0; i < orderByConditionFields.length; i++) {
12347                                    if (getDB().isSupportsInlineDistinct()) {
12348                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12349                                    }
12350                                    else {
12351                                            query.append(_ORDER_BY_ENTITY_TABLE);
12352                                    }
12353    
12354                                    query.append(orderByConditionFields[i]);
12355    
12356                                    if ((i + 1) < orderByConditionFields.length) {
12357                                            if (orderByComparator.isAscending() ^ previous) {
12358                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12359                                            }
12360                                            else {
12361                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12362                                            }
12363                                    }
12364                                    else {
12365                                            if (orderByComparator.isAscending() ^ previous) {
12366                                                    query.append(WHERE_GREATER_THAN);
12367                                            }
12368                                            else {
12369                                                    query.append(WHERE_LESSER_THAN);
12370                                            }
12371                                    }
12372                            }
12373    
12374                            query.append(ORDER_BY_CLAUSE);
12375    
12376                            String[] orderByFields = orderByComparator.getOrderByFields();
12377    
12378                            for (int i = 0; i < orderByFields.length; i++) {
12379                                    if (getDB().isSupportsInlineDistinct()) {
12380                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12381                                    }
12382                                    else {
12383                                            query.append(_ORDER_BY_ENTITY_TABLE);
12384                                    }
12385    
12386                                    query.append(orderByFields[i]);
12387    
12388                                    if ((i + 1) < orderByFields.length) {
12389                                            if (orderByComparator.isAscending() ^ previous) {
12390                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12391                                            }
12392                                            else {
12393                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12394                                            }
12395                                    }
12396                                    else {
12397                                            if (orderByComparator.isAscending() ^ previous) {
12398                                                    query.append(ORDER_BY_ASC);
12399                                            }
12400                                            else {
12401                                                    query.append(ORDER_BY_DESC);
12402                                            }
12403                                    }
12404                            }
12405                    }
12406                    else {
12407                            if (getDB().isSupportsInlineDistinct()) {
12408                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12409                            }
12410                            else {
12411                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12412                            }
12413                    }
12414    
12415                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12416                                    JournalArticle.class.getName(),
12417                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12418    
12419                    SQLQuery q = session.createSQLQuery(sql);
12420    
12421                    q.setFirstResult(0);
12422                    q.setMaxResults(2);
12423    
12424                    if (getDB().isSupportsInlineDistinct()) {
12425                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12426                    }
12427                    else {
12428                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12429                    }
12430    
12431                    QueryPos qPos = QueryPos.getInstance(q);
12432    
12433                    qPos.add(groupId);
12434    
12435                    if (bindTemplateId) {
12436                            qPos.add(templateId);
12437                    }
12438    
12439                    if (orderByComparator != null) {
12440                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12441    
12442                            for (Object value : values) {
12443                                    qPos.add(value);
12444                            }
12445                    }
12446    
12447                    List<JournalArticle> list = q.list();
12448    
12449                    if (list.size() == 2) {
12450                            return list.get(1);
12451                    }
12452                    else {
12453                            return null;
12454                    }
12455            }
12456    
12457            /**
12458             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
12459             *
12460             * @param groupId the group ID
12461             * @param templateId the template ID
12462             * @throws SystemException if a system exception occurred
12463             */
12464            @Override
12465            public void removeByG_T(long groupId, String templateId)
12466                    throws SystemException {
12467                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
12468                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12469                            remove(journalArticle);
12470                    }
12471            }
12472    
12473            /**
12474             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
12475             *
12476             * @param groupId the group ID
12477             * @param templateId the template ID
12478             * @return the number of matching journal articles
12479             * @throws SystemException if a system exception occurred
12480             */
12481            @Override
12482            public int countByG_T(long groupId, String templateId)
12483                    throws SystemException {
12484                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
12485    
12486                    Object[] finderArgs = new Object[] { groupId, templateId };
12487    
12488                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12489                                    this);
12490    
12491                    if (count == null) {
12492                            StringBundler query = new StringBundler(3);
12493    
12494                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12495    
12496                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12497    
12498                            boolean bindTemplateId = false;
12499    
12500                            if (templateId == null) {
12501                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12502                            }
12503                            else if (templateId.equals(StringPool.BLANK)) {
12504                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12505                            }
12506                            else {
12507                                    bindTemplateId = true;
12508    
12509                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12510                            }
12511    
12512                            String sql = query.toString();
12513    
12514                            Session session = null;
12515    
12516                            try {
12517                                    session = openSession();
12518    
12519                                    Query q = session.createQuery(sql);
12520    
12521                                    QueryPos qPos = QueryPos.getInstance(q);
12522    
12523                                    qPos.add(groupId);
12524    
12525                                    if (bindTemplateId) {
12526                                            qPos.add(templateId);
12527                                    }
12528    
12529                                    count = (Long)q.uniqueResult();
12530    
12531                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12532                            }
12533                            catch (Exception e) {
12534                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12535    
12536                                    throw processException(e);
12537                            }
12538                            finally {
12539                                    closeSession(session);
12540                            }
12541                    }
12542    
12543                    return count.intValue();
12544            }
12545    
12546            /**
12547             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12548             *
12549             * @param groupId the group ID
12550             * @param templateId the template ID
12551             * @return the number of matching journal articles that the user has permission to view
12552             * @throws SystemException if a system exception occurred
12553             */
12554            @Override
12555            public int filterCountByG_T(long groupId, String templateId)
12556                    throws SystemException {
12557                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12558                            return countByG_T(groupId, templateId);
12559                    }
12560    
12561                    StringBundler query = new StringBundler(3);
12562    
12563                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12564    
12565                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12566    
12567                    boolean bindTemplateId = false;
12568    
12569                    if (templateId == null) {
12570                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12571                    }
12572                    else if (templateId.equals(StringPool.BLANK)) {
12573                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12574                    }
12575                    else {
12576                            bindTemplateId = true;
12577    
12578                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12579                    }
12580    
12581                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12582                                    JournalArticle.class.getName(),
12583                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12584    
12585                    Session session = null;
12586    
12587                    try {
12588                            session = openSession();
12589    
12590                            SQLQuery q = session.createSQLQuery(sql);
12591    
12592                            q.addScalar(COUNT_COLUMN_NAME,
12593                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12594    
12595                            QueryPos qPos = QueryPos.getInstance(q);
12596    
12597                            qPos.add(groupId);
12598    
12599                            if (bindTemplateId) {
12600                                    qPos.add(templateId);
12601                            }
12602    
12603                            Long count = (Long)q.uniqueResult();
12604    
12605                            return count.intValue();
12606                    }
12607                    catch (Exception e) {
12608                            throw processException(e);
12609                    }
12610                    finally {
12611                            closeSession(session);
12612                    }
12613            }
12614    
12615            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
12616            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
12617            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
12618            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
12619            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12620                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12621                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12622                            "findByG_L",
12623                            new String[] {
12624                                    Long.class.getName(), String.class.getName(),
12625                                    
12626                            Integer.class.getName(), Integer.class.getName(),
12627                                    OrderByComparator.class.getName()
12628                            });
12629            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12630                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12631                            JournalArticleImpl.class,
12632                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
12633                            new String[] { Long.class.getName(), String.class.getName() },
12634                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12635                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
12636                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12637                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12638            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12639                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12640                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
12641                            new String[] { Long.class.getName(), String.class.getName() });
12642    
12643            /**
12644             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12645             *
12646             * @param groupId the group ID
12647             * @param layoutUuid the layout uuid
12648             * @return the matching journal articles
12649             * @throws SystemException if a system exception occurred
12650             */
12651            @Override
12652            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
12653                    throws SystemException {
12654                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
12655                            QueryUtil.ALL_POS, null);
12656            }
12657    
12658            /**
12659             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12660             *
12661             * <p>
12662             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12663             * </p>
12664             *
12665             * @param groupId the group ID
12666             * @param layoutUuid the layout uuid
12667             * @param start the lower bound of the range of journal articles
12668             * @param end the upper bound of the range of journal articles (not inclusive)
12669             * @return the range of matching journal articles
12670             * @throws SystemException if a system exception occurred
12671             */
12672            @Override
12673            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12674                    int start, int end) throws SystemException {
12675                    return findByG_L(groupId, layoutUuid, start, end, null);
12676            }
12677    
12678            /**
12679             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12680             *
12681             * <p>
12682             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12683             * </p>
12684             *
12685             * @param groupId the group ID
12686             * @param layoutUuid the layout uuid
12687             * @param start the lower bound of the range of journal articles
12688             * @param end the upper bound of the range of journal articles (not inclusive)
12689             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12690             * @return the ordered range of matching journal articles
12691             * @throws SystemException if a system exception occurred
12692             */
12693            @Override
12694            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12695                    int start, int end, OrderByComparator orderByComparator)
12696                    throws SystemException {
12697                    boolean pagination = true;
12698                    FinderPath finderPath = null;
12699                    Object[] finderArgs = null;
12700    
12701                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12702                                    (orderByComparator == null)) {
12703                            pagination = false;
12704                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
12705                            finderArgs = new Object[] { groupId, layoutUuid };
12706                    }
12707                    else {
12708                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
12709                            finderArgs = new Object[] {
12710                                            groupId, layoutUuid,
12711                                            
12712                                            start, end, orderByComparator
12713                                    };
12714                    }
12715    
12716                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12717                                    finderArgs, this);
12718    
12719                    if ((list != null) && !list.isEmpty()) {
12720                            for (JournalArticle journalArticle : list) {
12721                                    if ((groupId != journalArticle.getGroupId()) ||
12722                                                    !Validator.equals(layoutUuid,
12723                                                            journalArticle.getLayoutUuid())) {
12724                                            list = null;
12725    
12726                                            break;
12727                                    }
12728                            }
12729                    }
12730    
12731                    if (list == null) {
12732                            StringBundler query = null;
12733    
12734                            if (orderByComparator != null) {
12735                                    query = new StringBundler(4 +
12736                                                    (orderByComparator.getOrderByFields().length * 3));
12737                            }
12738                            else {
12739                                    query = new StringBundler(4);
12740                            }
12741    
12742                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12743    
12744                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12745    
12746                            boolean bindLayoutUuid = false;
12747    
12748                            if (layoutUuid == null) {
12749                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12750                            }
12751                            else if (layoutUuid.equals(StringPool.BLANK)) {
12752                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12753                            }
12754                            else {
12755                                    bindLayoutUuid = true;
12756    
12757                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12758                            }
12759    
12760                            if (orderByComparator != null) {
12761                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12762                                            orderByComparator);
12763                            }
12764                            else
12765                             if (pagination) {
12766                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12767                            }
12768    
12769                            String sql = query.toString();
12770    
12771                            Session session = null;
12772    
12773                            try {
12774                                    session = openSession();
12775    
12776                                    Query q = session.createQuery(sql);
12777    
12778                                    QueryPos qPos = QueryPos.getInstance(q);
12779    
12780                                    qPos.add(groupId);
12781    
12782                                    if (bindLayoutUuid) {
12783                                            qPos.add(layoutUuid);
12784                                    }
12785    
12786                                    if (!pagination) {
12787                                            list = (List<JournalArticle>)QueryUtil.list(q,
12788                                                            getDialect(), start, end, false);
12789    
12790                                            Collections.sort(list);
12791    
12792                                            list = new UnmodifiableList<JournalArticle>(list);
12793                                    }
12794                                    else {
12795                                            list = (List<JournalArticle>)QueryUtil.list(q,
12796                                                            getDialect(), start, end);
12797                                    }
12798    
12799                                    cacheResult(list);
12800    
12801                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12802                            }
12803                            catch (Exception e) {
12804                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12805    
12806                                    throw processException(e);
12807                            }
12808                            finally {
12809                                    closeSession(session);
12810                            }
12811                    }
12812    
12813                    return list;
12814            }
12815    
12816            /**
12817             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12818             *
12819             * @param groupId the group ID
12820             * @param layoutUuid the layout uuid
12821             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12822             * @return the first matching journal article
12823             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12824             * @throws SystemException if a system exception occurred
12825             */
12826            @Override
12827            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
12828                    OrderByComparator orderByComparator)
12829                    throws NoSuchArticleException, SystemException {
12830                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
12831                                    orderByComparator);
12832    
12833                    if (journalArticle != null) {
12834                            return journalArticle;
12835                    }
12836    
12837                    StringBundler msg = new StringBundler(6);
12838    
12839                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12840    
12841                    msg.append("groupId=");
12842                    msg.append(groupId);
12843    
12844                    msg.append(", layoutUuid=");
12845                    msg.append(layoutUuid);
12846    
12847                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12848    
12849                    throw new NoSuchArticleException(msg.toString());
12850            }
12851    
12852            /**
12853             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12854             *
12855             * @param groupId the group ID
12856             * @param layoutUuid the layout uuid
12857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12858             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12859             * @throws SystemException if a system exception occurred
12860             */
12861            @Override
12862            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
12863                    OrderByComparator orderByComparator) throws SystemException {
12864                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
12865                                    orderByComparator);
12866    
12867                    if (!list.isEmpty()) {
12868                            return list.get(0);
12869                    }
12870    
12871                    return null;
12872            }
12873    
12874            /**
12875             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12876             *
12877             * @param groupId the group ID
12878             * @param layoutUuid the layout uuid
12879             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12880             * @return the last matching journal article
12881             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12882             * @throws SystemException if a system exception occurred
12883             */
12884            @Override
12885            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
12886                    OrderByComparator orderByComparator)
12887                    throws NoSuchArticleException, SystemException {
12888                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
12889                                    orderByComparator);
12890    
12891                    if (journalArticle != null) {
12892                            return journalArticle;
12893                    }
12894    
12895                    StringBundler msg = new StringBundler(6);
12896    
12897                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12898    
12899                    msg.append("groupId=");
12900                    msg.append(groupId);
12901    
12902                    msg.append(", layoutUuid=");
12903                    msg.append(layoutUuid);
12904    
12905                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12906    
12907                    throw new NoSuchArticleException(msg.toString());
12908            }
12909    
12910            /**
12911             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12912             *
12913             * @param groupId the group ID
12914             * @param layoutUuid the layout uuid
12915             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12916             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12917             * @throws SystemException if a system exception occurred
12918             */
12919            @Override
12920            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
12921                    OrderByComparator orderByComparator) throws SystemException {
12922                    int count = countByG_L(groupId, layoutUuid);
12923    
12924                    if (count == 0) {
12925                            return null;
12926                    }
12927    
12928                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
12929                                    count, orderByComparator);
12930    
12931                    if (!list.isEmpty()) {
12932                            return list.get(0);
12933                    }
12934    
12935                    return null;
12936            }
12937    
12938            /**
12939             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12940             *
12941             * @param id the primary key of the current journal article
12942             * @param groupId the group ID
12943             * @param layoutUuid the layout uuid
12944             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12945             * @return the previous, current, and next journal article
12946             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12947             * @throws SystemException if a system exception occurred
12948             */
12949            @Override
12950            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
12951                    String layoutUuid, OrderByComparator orderByComparator)
12952                    throws NoSuchArticleException, SystemException {
12953                    JournalArticle journalArticle = findByPrimaryKey(id);
12954    
12955                    Session session = null;
12956    
12957                    try {
12958                            session = openSession();
12959    
12960                            JournalArticle[] array = new JournalArticleImpl[3];
12961    
12962                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12963                                            layoutUuid, orderByComparator, true);
12964    
12965                            array[1] = journalArticle;
12966    
12967                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12968                                            layoutUuid, orderByComparator, false);
12969    
12970                            return array;
12971                    }
12972                    catch (Exception e) {
12973                            throw processException(e);
12974                    }
12975                    finally {
12976                            closeSession(session);
12977                    }
12978            }
12979    
12980            protected JournalArticle getByG_L_PrevAndNext(Session session,
12981                    JournalArticle journalArticle, long groupId, String layoutUuid,
12982                    OrderByComparator orderByComparator, boolean previous) {
12983                    StringBundler query = null;
12984    
12985                    if (orderByComparator != null) {
12986                            query = new StringBundler(6 +
12987                                            (orderByComparator.getOrderByFields().length * 6));
12988                    }
12989                    else {
12990                            query = new StringBundler(3);
12991                    }
12992    
12993                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12994    
12995                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12996    
12997                    boolean bindLayoutUuid = false;
12998    
12999                    if (layoutUuid == null) {
13000                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13001                    }
13002                    else if (layoutUuid.equals(StringPool.BLANK)) {
13003                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13004                    }
13005                    else {
13006                            bindLayoutUuid = true;
13007    
13008                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13009                    }
13010    
13011                    if (orderByComparator != null) {
13012                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13013    
13014                            if (orderByConditionFields.length > 0) {
13015                                    query.append(WHERE_AND);
13016                            }
13017    
13018                            for (int i = 0; i < orderByConditionFields.length; i++) {
13019                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13020                                    query.append(orderByConditionFields[i]);
13021    
13022                                    if ((i + 1) < orderByConditionFields.length) {
13023                                            if (orderByComparator.isAscending() ^ previous) {
13024                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13025                                            }
13026                                            else {
13027                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13028                                            }
13029                                    }
13030                                    else {
13031                                            if (orderByComparator.isAscending() ^ previous) {
13032                                                    query.append(WHERE_GREATER_THAN);
13033                                            }
13034                                            else {
13035                                                    query.append(WHERE_LESSER_THAN);
13036                                            }
13037                                    }
13038                            }
13039    
13040                            query.append(ORDER_BY_CLAUSE);
13041    
13042                            String[] orderByFields = orderByComparator.getOrderByFields();
13043    
13044                            for (int i = 0; i < orderByFields.length; i++) {
13045                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13046                                    query.append(orderByFields[i]);
13047    
13048                                    if ((i + 1) < orderByFields.length) {
13049                                            if (orderByComparator.isAscending() ^ previous) {
13050                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13051                                            }
13052                                            else {
13053                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13054                                            }
13055                                    }
13056                                    else {
13057                                            if (orderByComparator.isAscending() ^ previous) {
13058                                                    query.append(ORDER_BY_ASC);
13059                                            }
13060                                            else {
13061                                                    query.append(ORDER_BY_DESC);
13062                                            }
13063                                    }
13064                            }
13065                    }
13066                    else {
13067                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13068                    }
13069    
13070                    String sql = query.toString();
13071    
13072                    Query q = session.createQuery(sql);
13073    
13074                    q.setFirstResult(0);
13075                    q.setMaxResults(2);
13076    
13077                    QueryPos qPos = QueryPos.getInstance(q);
13078    
13079                    qPos.add(groupId);
13080    
13081                    if (bindLayoutUuid) {
13082                            qPos.add(layoutUuid);
13083                    }
13084    
13085                    if (orderByComparator != null) {
13086                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13087    
13088                            for (Object value : values) {
13089                                    qPos.add(value);
13090                            }
13091                    }
13092    
13093                    List<JournalArticle> list = q.list();
13094    
13095                    if (list.size() == 2) {
13096                            return list.get(1);
13097                    }
13098                    else {
13099                            return null;
13100                    }
13101            }
13102    
13103            /**
13104             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13105             *
13106             * @param groupId the group ID
13107             * @param layoutUuid the layout uuid
13108             * @return the matching journal articles that the user has permission to view
13109             * @throws SystemException if a system exception occurred
13110             */
13111            @Override
13112            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
13113                    throws SystemException {
13114                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13115                            QueryUtil.ALL_POS, null);
13116            }
13117    
13118            /**
13119             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13120             *
13121             * <p>
13122             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13123             * </p>
13124             *
13125             * @param groupId the group ID
13126             * @param layoutUuid the layout uuid
13127             * @param start the lower bound of the range of journal articles
13128             * @param end the upper bound of the range of journal articles (not inclusive)
13129             * @return the range of matching journal articles that the user has permission to view
13130             * @throws SystemException if a system exception occurred
13131             */
13132            @Override
13133            public List<JournalArticle> filterFindByG_L(long groupId,
13134                    String layoutUuid, int start, int end) throws SystemException {
13135                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
13136            }
13137    
13138            /**
13139             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
13140             *
13141             * <p>
13142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13143             * </p>
13144             *
13145             * @param groupId the group ID
13146             * @param layoutUuid the layout uuid
13147             * @param start the lower bound of the range of journal articles
13148             * @param end the upper bound of the range of journal articles (not inclusive)
13149             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13150             * @return the ordered range of matching journal articles that the user has permission to view
13151             * @throws SystemException if a system exception occurred
13152             */
13153            @Override
13154            public List<JournalArticle> filterFindByG_L(long groupId,
13155                    String layoutUuid, int start, int end,
13156                    OrderByComparator orderByComparator) throws SystemException {
13157                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13158                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
13159                    }
13160    
13161                    StringBundler query = null;
13162    
13163                    if (orderByComparator != null) {
13164                            query = new StringBundler(4 +
13165                                            (orderByComparator.getOrderByFields().length * 3));
13166                    }
13167                    else {
13168                            query = new StringBundler(4);
13169                    }
13170    
13171                    if (getDB().isSupportsInlineDistinct()) {
13172                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13173                    }
13174                    else {
13175                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13176                    }
13177    
13178                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13179    
13180                    boolean bindLayoutUuid = false;
13181    
13182                    if (layoutUuid == null) {
13183                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13184                    }
13185                    else if (layoutUuid.equals(StringPool.BLANK)) {
13186                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13187                    }
13188                    else {
13189                            bindLayoutUuid = true;
13190    
13191                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13192                    }
13193    
13194                    if (!getDB().isSupportsInlineDistinct()) {
13195                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13196                    }
13197    
13198                    if (orderByComparator != null) {
13199                            if (getDB().isSupportsInlineDistinct()) {
13200                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13201                                            orderByComparator, true);
13202                            }
13203                            else {
13204                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13205                                            orderByComparator, true);
13206                            }
13207                    }
13208                    else {
13209                            if (getDB().isSupportsInlineDistinct()) {
13210                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13211                            }
13212                            else {
13213                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13214                            }
13215                    }
13216    
13217                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13218                                    JournalArticle.class.getName(),
13219                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13220    
13221                    Session session = null;
13222    
13223                    try {
13224                            session = openSession();
13225    
13226                            SQLQuery q = session.createSQLQuery(sql);
13227    
13228                            if (getDB().isSupportsInlineDistinct()) {
13229                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13230                            }
13231                            else {
13232                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13233                            }
13234    
13235                            QueryPos qPos = QueryPos.getInstance(q);
13236    
13237                            qPos.add(groupId);
13238    
13239                            if (bindLayoutUuid) {
13240                                    qPos.add(layoutUuid);
13241                            }
13242    
13243                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13244                                    end);
13245                    }
13246                    catch (Exception e) {
13247                            throw processException(e);
13248                    }
13249                    finally {
13250                            closeSession(session);
13251                    }
13252            }
13253    
13254            /**
13255             * 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;.
13256             *
13257             * @param id the primary key of the current journal article
13258             * @param groupId the group ID
13259             * @param layoutUuid the layout uuid
13260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13261             * @return the previous, current, and next journal article
13262             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13263             * @throws SystemException if a system exception occurred
13264             */
13265            @Override
13266            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
13267                    String layoutUuid, OrderByComparator orderByComparator)
13268                    throws NoSuchArticleException, SystemException {
13269                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13270                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
13271                                    orderByComparator);
13272                    }
13273    
13274                    JournalArticle journalArticle = findByPrimaryKey(id);
13275    
13276                    Session session = null;
13277    
13278                    try {
13279                            session = openSession();
13280    
13281                            JournalArticle[] array = new JournalArticleImpl[3];
13282    
13283                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
13284                                            groupId, layoutUuid, orderByComparator, true);
13285    
13286                            array[1] = journalArticle;
13287    
13288                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
13289                                            groupId, layoutUuid, orderByComparator, false);
13290    
13291                            return array;
13292                    }
13293                    catch (Exception e) {
13294                            throw processException(e);
13295                    }
13296                    finally {
13297                            closeSession(session);
13298                    }
13299            }
13300    
13301            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
13302                    JournalArticle journalArticle, long groupId, String layoutUuid,
13303                    OrderByComparator orderByComparator, boolean previous) {
13304                    StringBundler query = null;
13305    
13306                    if (orderByComparator != null) {
13307                            query = new StringBundler(6 +
13308                                            (orderByComparator.getOrderByFields().length * 6));
13309                    }
13310                    else {
13311                            query = new StringBundler(3);
13312                    }
13313    
13314                    if (getDB().isSupportsInlineDistinct()) {
13315                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13316                    }
13317                    else {
13318                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13319                    }
13320    
13321                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13322    
13323                    boolean bindLayoutUuid = false;
13324    
13325                    if (layoutUuid == null) {
13326                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13327                    }
13328                    else if (layoutUuid.equals(StringPool.BLANK)) {
13329                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13330                    }
13331                    else {
13332                            bindLayoutUuid = true;
13333    
13334                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13335                    }
13336    
13337                    if (!getDB().isSupportsInlineDistinct()) {
13338                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13339                    }
13340    
13341                    if (orderByComparator != null) {
13342                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13343    
13344                            if (orderByConditionFields.length > 0) {
13345                                    query.append(WHERE_AND);
13346                            }
13347    
13348                            for (int i = 0; i < orderByConditionFields.length; i++) {
13349                                    if (getDB().isSupportsInlineDistinct()) {
13350                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13351                                    }
13352                                    else {
13353                                            query.append(_ORDER_BY_ENTITY_TABLE);
13354                                    }
13355    
13356                                    query.append(orderByConditionFields[i]);
13357    
13358                                    if ((i + 1) < orderByConditionFields.length) {
13359                                            if (orderByComparator.isAscending() ^ previous) {
13360                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13361                                            }
13362                                            else {
13363                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13364                                            }
13365                                    }
13366                                    else {
13367                                            if (orderByComparator.isAscending() ^ previous) {
13368                                                    query.append(WHERE_GREATER_THAN);
13369                                            }
13370                                            else {
13371                                                    query.append(WHERE_LESSER_THAN);
13372                                            }
13373                                    }
13374                            }
13375    
13376                            query.append(ORDER_BY_CLAUSE);
13377    
13378                            String[] orderByFields = orderByComparator.getOrderByFields();
13379    
13380                            for (int i = 0; i < orderByFields.length; i++) {
13381                                    if (getDB().isSupportsInlineDistinct()) {
13382                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13383                                    }
13384                                    else {
13385                                            query.append(_ORDER_BY_ENTITY_TABLE);
13386                                    }
13387    
13388                                    query.append(orderByFields[i]);
13389    
13390                                    if ((i + 1) < orderByFields.length) {
13391                                            if (orderByComparator.isAscending() ^ previous) {
13392                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13393                                            }
13394                                            else {
13395                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13396                                            }
13397                                    }
13398                                    else {
13399                                            if (orderByComparator.isAscending() ^ previous) {
13400                                                    query.append(ORDER_BY_ASC);
13401                                            }
13402                                            else {
13403                                                    query.append(ORDER_BY_DESC);
13404                                            }
13405                                    }
13406                            }
13407                    }
13408                    else {
13409                            if (getDB().isSupportsInlineDistinct()) {
13410                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13411                            }
13412                            else {
13413                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13414                            }
13415                    }
13416    
13417                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13418                                    JournalArticle.class.getName(),
13419                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13420    
13421                    SQLQuery q = session.createSQLQuery(sql);
13422    
13423                    q.setFirstResult(0);
13424                    q.setMaxResults(2);
13425    
13426                    if (getDB().isSupportsInlineDistinct()) {
13427                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13428                    }
13429                    else {
13430                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13431                    }
13432    
13433                    QueryPos qPos = QueryPos.getInstance(q);
13434    
13435                    qPos.add(groupId);
13436    
13437                    if (bindLayoutUuid) {
13438                            qPos.add(layoutUuid);
13439                    }
13440    
13441                    if (orderByComparator != null) {
13442                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13443    
13444                            for (Object value : values) {
13445                                    qPos.add(value);
13446                            }
13447                    }
13448    
13449                    List<JournalArticle> list = q.list();
13450    
13451                    if (list.size() == 2) {
13452                            return list.get(1);
13453                    }
13454                    else {
13455                            return null;
13456                    }
13457            }
13458    
13459            /**
13460             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
13461             *
13462             * @param groupId the group ID
13463             * @param layoutUuid the layout uuid
13464             * @throws SystemException if a system exception occurred
13465             */
13466            @Override
13467            public void removeByG_L(long groupId, String layoutUuid)
13468                    throws SystemException {
13469                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
13470                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13471                            remove(journalArticle);
13472                    }
13473            }
13474    
13475            /**
13476             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
13477             *
13478             * @param groupId the group ID
13479             * @param layoutUuid the layout uuid
13480             * @return the number of matching journal articles
13481             * @throws SystemException if a system exception occurred
13482             */
13483            @Override
13484            public int countByG_L(long groupId, String layoutUuid)
13485                    throws SystemException {
13486                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
13487    
13488                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
13489    
13490                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13491                                    this);
13492    
13493                    if (count == null) {
13494                            StringBundler query = new StringBundler(3);
13495    
13496                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13497    
13498                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13499    
13500                            boolean bindLayoutUuid = false;
13501    
13502                            if (layoutUuid == null) {
13503                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13504                            }
13505                            else if (layoutUuid.equals(StringPool.BLANK)) {
13506                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13507                            }
13508                            else {
13509                                    bindLayoutUuid = true;
13510    
13511                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13512                            }
13513    
13514                            String sql = query.toString();
13515    
13516                            Session session = null;
13517    
13518                            try {
13519                                    session = openSession();
13520    
13521                                    Query q = session.createQuery(sql);
13522    
13523                                    QueryPos qPos = QueryPos.getInstance(q);
13524    
13525                                    qPos.add(groupId);
13526    
13527                                    if (bindLayoutUuid) {
13528                                            qPos.add(layoutUuid);
13529                                    }
13530    
13531                                    count = (Long)q.uniqueResult();
13532    
13533                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13534                            }
13535                            catch (Exception e) {
13536                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13537    
13538                                    throw processException(e);
13539                            }
13540                            finally {
13541                                    closeSession(session);
13542                            }
13543                    }
13544    
13545                    return count.intValue();
13546            }
13547    
13548            /**
13549             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13550             *
13551             * @param groupId the group ID
13552             * @param layoutUuid the layout uuid
13553             * @return the number of matching journal articles that the user has permission to view
13554             * @throws SystemException if a system exception occurred
13555             */
13556            @Override
13557            public int filterCountByG_L(long groupId, String layoutUuid)
13558                    throws SystemException {
13559                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13560                            return countByG_L(groupId, layoutUuid);
13561                    }
13562    
13563                    StringBundler query = new StringBundler(3);
13564    
13565                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13566    
13567                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13568    
13569                    boolean bindLayoutUuid = false;
13570    
13571                    if (layoutUuid == null) {
13572                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13573                    }
13574                    else if (layoutUuid.equals(StringPool.BLANK)) {
13575                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13576                    }
13577                    else {
13578                            bindLayoutUuid = true;
13579    
13580                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13581                    }
13582    
13583                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13584                                    JournalArticle.class.getName(),
13585                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13586    
13587                    Session session = null;
13588    
13589                    try {
13590                            session = openSession();
13591    
13592                            SQLQuery q = session.createSQLQuery(sql);
13593    
13594                            q.addScalar(COUNT_COLUMN_NAME,
13595                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13596    
13597                            QueryPos qPos = QueryPos.getInstance(q);
13598    
13599                            qPos.add(groupId);
13600    
13601                            if (bindLayoutUuid) {
13602                                    qPos.add(layoutUuid);
13603                            }
13604    
13605                            Long count = (Long)q.uniqueResult();
13606    
13607                            return count.intValue();
13608                    }
13609                    catch (Exception e) {
13610                            throw processException(e);
13611                    }
13612                    finally {
13613                            closeSession(session);
13614                    }
13615            }
13616    
13617            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
13618            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
13619            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
13620            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
13621            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13622                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13623                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13624                            "findByG_ST",
13625                            new String[] {
13626                                    Long.class.getName(), Integer.class.getName(),
13627                                    
13628                            Integer.class.getName(), Integer.class.getName(),
13629                                    OrderByComparator.class.getName()
13630                            });
13631            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13632                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13633                            JournalArticleImpl.class,
13634                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
13635                            new String[] { Long.class.getName(), Integer.class.getName() },
13636                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13637                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
13638                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13639                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13640            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13641                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13642                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
13643                            new String[] { Long.class.getName(), Integer.class.getName() });
13644    
13645            /**
13646             * Returns all the journal articles where groupId = &#63; and status = &#63;.
13647             *
13648             * @param groupId the group ID
13649             * @param status the status
13650             * @return the matching journal articles
13651             * @throws SystemException if a system exception occurred
13652             */
13653            @Override
13654            public List<JournalArticle> findByG_ST(long groupId, int status)
13655                    throws SystemException {
13656                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
13657                            QueryUtil.ALL_POS, null);
13658            }
13659    
13660            /**
13661             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
13662             *
13663             * <p>
13664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13665             * </p>
13666             *
13667             * @param groupId the group ID
13668             * @param status the status
13669             * @param start the lower bound of the range of journal articles
13670             * @param end the upper bound of the range of journal articles (not inclusive)
13671             * @return the range of matching journal articles
13672             * @throws SystemException if a system exception occurred
13673             */
13674            @Override
13675            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13676                    int end) throws SystemException {
13677                    return findByG_ST(groupId, status, start, end, null);
13678            }
13679    
13680            /**
13681             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
13682             *
13683             * <p>
13684             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13685             * </p>
13686             *
13687             * @param groupId the group ID
13688             * @param status the status
13689             * @param start the lower bound of the range of journal articles
13690             * @param end the upper bound of the range of journal articles (not inclusive)
13691             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13692             * @return the ordered range of matching journal articles
13693             * @throws SystemException if a system exception occurred
13694             */
13695            @Override
13696            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13697                    int end, OrderByComparator orderByComparator) throws SystemException {
13698                    boolean pagination = true;
13699                    FinderPath finderPath = null;
13700                    Object[] finderArgs = null;
13701    
13702                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13703                                    (orderByComparator == null)) {
13704                            pagination = false;
13705                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
13706                            finderArgs = new Object[] { groupId, status };
13707                    }
13708                    else {
13709                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
13710                            finderArgs = new Object[] {
13711                                            groupId, status,
13712                                            
13713                                            start, end, orderByComparator
13714                                    };
13715                    }
13716    
13717                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13718                                    finderArgs, this);
13719    
13720                    if ((list != null) && !list.isEmpty()) {
13721                            for (JournalArticle journalArticle : list) {
13722                                    if ((groupId != journalArticle.getGroupId()) ||
13723                                                    (status != journalArticle.getStatus())) {
13724                                            list = null;
13725    
13726                                            break;
13727                                    }
13728                            }
13729                    }
13730    
13731                    if (list == null) {
13732                            StringBundler query = null;
13733    
13734                            if (orderByComparator != null) {
13735                                    query = new StringBundler(4 +
13736                                                    (orderByComparator.getOrderByFields().length * 3));
13737                            }
13738                            else {
13739                                    query = new StringBundler(4);
13740                            }
13741    
13742                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13743    
13744                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13745    
13746                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13747    
13748                            if (orderByComparator != null) {
13749                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13750                                            orderByComparator);
13751                            }
13752                            else
13753                             if (pagination) {
13754                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13755                            }
13756    
13757                            String sql = query.toString();
13758    
13759                            Session session = null;
13760    
13761                            try {
13762                                    session = openSession();
13763    
13764                                    Query q = session.createQuery(sql);
13765    
13766                                    QueryPos qPos = QueryPos.getInstance(q);
13767    
13768                                    qPos.add(groupId);
13769    
13770                                    qPos.add(status);
13771    
13772                                    if (!pagination) {
13773                                            list = (List<JournalArticle>)QueryUtil.list(q,
13774                                                            getDialect(), start, end, false);
13775    
13776                                            Collections.sort(list);
13777    
13778                                            list = new UnmodifiableList<JournalArticle>(list);
13779                                    }
13780                                    else {
13781                                            list = (List<JournalArticle>)QueryUtil.list(q,
13782                                                            getDialect(), start, end);
13783                                    }
13784    
13785                                    cacheResult(list);
13786    
13787                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13788                            }
13789                            catch (Exception e) {
13790                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13791    
13792                                    throw processException(e);
13793                            }
13794                            finally {
13795                                    closeSession(session);
13796                            }
13797                    }
13798    
13799                    return list;
13800            }
13801    
13802            /**
13803             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13804             *
13805             * @param groupId the group ID
13806             * @param status the status
13807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13808             * @return the first matching journal article
13809             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13810             * @throws SystemException if a system exception occurred
13811             */
13812            @Override
13813            public JournalArticle findByG_ST_First(long groupId, int status,
13814                    OrderByComparator orderByComparator)
13815                    throws NoSuchArticleException, SystemException {
13816                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
13817                                    orderByComparator);
13818    
13819                    if (journalArticle != null) {
13820                            return journalArticle;
13821                    }
13822    
13823                    StringBundler msg = new StringBundler(6);
13824    
13825                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13826    
13827                    msg.append("groupId=");
13828                    msg.append(groupId);
13829    
13830                    msg.append(", status=");
13831                    msg.append(status);
13832    
13833                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13834    
13835                    throw new NoSuchArticleException(msg.toString());
13836            }
13837    
13838            /**
13839             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13840             *
13841             * @param groupId the group ID
13842             * @param status the status
13843             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13844             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13845             * @throws SystemException if a system exception occurred
13846             */
13847            @Override
13848            public JournalArticle fetchByG_ST_First(long groupId, int status,
13849                    OrderByComparator orderByComparator) throws SystemException {
13850                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
13851                                    orderByComparator);
13852    
13853                    if (!list.isEmpty()) {
13854                            return list.get(0);
13855                    }
13856    
13857                    return null;
13858            }
13859    
13860            /**
13861             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13862             *
13863             * @param groupId the group ID
13864             * @param status the status
13865             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13866             * @return the last matching journal article
13867             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13868             * @throws SystemException if a system exception occurred
13869             */
13870            @Override
13871            public JournalArticle findByG_ST_Last(long groupId, int status,
13872                    OrderByComparator orderByComparator)
13873                    throws NoSuchArticleException, SystemException {
13874                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
13875                                    orderByComparator);
13876    
13877                    if (journalArticle != null) {
13878                            return journalArticle;
13879                    }
13880    
13881                    StringBundler msg = new StringBundler(6);
13882    
13883                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13884    
13885                    msg.append("groupId=");
13886                    msg.append(groupId);
13887    
13888                    msg.append(", status=");
13889                    msg.append(status);
13890    
13891                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13892    
13893                    throw new NoSuchArticleException(msg.toString());
13894            }
13895    
13896            /**
13897             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13898             *
13899             * @param groupId the group ID
13900             * @param status the status
13901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13902             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13903             * @throws SystemException if a system exception occurred
13904             */
13905            @Override
13906            public JournalArticle fetchByG_ST_Last(long groupId, int status,
13907                    OrderByComparator orderByComparator) throws SystemException {
13908                    int count = countByG_ST(groupId, status);
13909    
13910                    if (count == 0) {
13911                            return null;
13912                    }
13913    
13914                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
13915                                    count, orderByComparator);
13916    
13917                    if (!list.isEmpty()) {
13918                            return list.get(0);
13919                    }
13920    
13921                    return null;
13922            }
13923    
13924            /**
13925             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
13926             *
13927             * @param id the primary key of the current journal article
13928             * @param groupId the group ID
13929             * @param status the status
13930             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13931             * @return the previous, current, and next journal article
13932             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13933             * @throws SystemException if a system exception occurred
13934             */
13935            @Override
13936            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
13937                    int status, OrderByComparator orderByComparator)
13938                    throws NoSuchArticleException, SystemException {
13939                    JournalArticle journalArticle = findByPrimaryKey(id);
13940    
13941                    Session session = null;
13942    
13943                    try {
13944                            session = openSession();
13945    
13946                            JournalArticle[] array = new JournalArticleImpl[3];
13947    
13948                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13949                                            status, orderByComparator, true);
13950    
13951                            array[1] = journalArticle;
13952    
13953                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13954                                            status, orderByComparator, false);
13955    
13956                            return array;
13957                    }
13958                    catch (Exception e) {
13959                            throw processException(e);
13960                    }
13961                    finally {
13962                            closeSession(session);
13963                    }
13964            }
13965    
13966            protected JournalArticle getByG_ST_PrevAndNext(Session session,
13967                    JournalArticle journalArticle, long groupId, int status,
13968                    OrderByComparator orderByComparator, boolean previous) {
13969                    StringBundler query = null;
13970    
13971                    if (orderByComparator != null) {
13972                            query = new StringBundler(6 +
13973                                            (orderByComparator.getOrderByFields().length * 6));
13974                    }
13975                    else {
13976                            query = new StringBundler(3);
13977                    }
13978    
13979                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13980    
13981                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13982    
13983                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13984    
13985                    if (orderByComparator != null) {
13986                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13987    
13988                            if (orderByConditionFields.length > 0) {
13989                                    query.append(WHERE_AND);
13990                            }
13991    
13992                            for (int i = 0; i < orderByConditionFields.length; i++) {
13993                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13994                                    query.append(orderByConditionFields[i]);
13995    
13996                                    if ((i + 1) < orderByConditionFields.length) {
13997                                            if (orderByComparator.isAscending() ^ previous) {
13998                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13999                                            }
14000                                            else {
14001                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14002                                            }
14003                                    }
14004                                    else {
14005                                            if (orderByComparator.isAscending() ^ previous) {
14006                                                    query.append(WHERE_GREATER_THAN);
14007                                            }
14008                                            else {
14009                                                    query.append(WHERE_LESSER_THAN);
14010                                            }
14011                                    }
14012                            }
14013    
14014                            query.append(ORDER_BY_CLAUSE);
14015    
14016                            String[] orderByFields = orderByComparator.getOrderByFields();
14017    
14018                            for (int i = 0; i < orderByFields.length; i++) {
14019                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14020                                    query.append(orderByFields[i]);
14021    
14022                                    if ((i + 1) < orderByFields.length) {
14023                                            if (orderByComparator.isAscending() ^ previous) {
14024                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14025                                            }
14026                                            else {
14027                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14028                                            }
14029                                    }
14030                                    else {
14031                                            if (orderByComparator.isAscending() ^ previous) {
14032                                                    query.append(ORDER_BY_ASC);
14033                                            }
14034                                            else {
14035                                                    query.append(ORDER_BY_DESC);
14036                                            }
14037                                    }
14038                            }
14039                    }
14040                    else {
14041                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14042                    }
14043    
14044                    String sql = query.toString();
14045    
14046                    Query q = session.createQuery(sql);
14047    
14048                    q.setFirstResult(0);
14049                    q.setMaxResults(2);
14050    
14051                    QueryPos qPos = QueryPos.getInstance(q);
14052    
14053                    qPos.add(groupId);
14054    
14055                    qPos.add(status);
14056    
14057                    if (orderByComparator != null) {
14058                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14059    
14060                            for (Object value : values) {
14061                                    qPos.add(value);
14062                            }
14063                    }
14064    
14065                    List<JournalArticle> list = q.list();
14066    
14067                    if (list.size() == 2) {
14068                            return list.get(1);
14069                    }
14070                    else {
14071                            return null;
14072                    }
14073            }
14074    
14075            /**
14076             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14077             *
14078             * @param groupId the group ID
14079             * @param status the status
14080             * @return the matching journal articles that the user has permission to view
14081             * @throws SystemException if a system exception occurred
14082             */
14083            @Override
14084            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
14085                    throws SystemException {
14086                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
14087                            QueryUtil.ALL_POS, null);
14088            }
14089    
14090            /**
14091             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14092             *
14093             * <p>
14094             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14095             * </p>
14096             *
14097             * @param groupId the group ID
14098             * @param status the status
14099             * @param start the lower bound of the range of journal articles
14100             * @param end the upper bound of the range of journal articles (not inclusive)
14101             * @return the range of matching journal articles that the user has permission to view
14102             * @throws SystemException if a system exception occurred
14103             */
14104            @Override
14105            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14106                    int start, int end) throws SystemException {
14107                    return filterFindByG_ST(groupId, status, start, end, null);
14108            }
14109    
14110            /**
14111             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
14112             *
14113             * <p>
14114             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14115             * </p>
14116             *
14117             * @param groupId the group ID
14118             * @param status the status
14119             * @param start the lower bound of the range of journal articles
14120             * @param end the upper bound of the range of journal articles (not inclusive)
14121             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14122             * @return the ordered range of matching journal articles that the user has permission to view
14123             * @throws SystemException if a system exception occurred
14124             */
14125            @Override
14126            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14127                    int start, int end, OrderByComparator orderByComparator)
14128                    throws SystemException {
14129                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14130                            return findByG_ST(groupId, status, start, end, orderByComparator);
14131                    }
14132    
14133                    StringBundler query = null;
14134    
14135                    if (orderByComparator != null) {
14136                            query = new StringBundler(4 +
14137                                            (orderByComparator.getOrderByFields().length * 3));
14138                    }
14139                    else {
14140                            query = new StringBundler(4);
14141                    }
14142    
14143                    if (getDB().isSupportsInlineDistinct()) {
14144                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14145                    }
14146                    else {
14147                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14148                    }
14149    
14150                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14151    
14152                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14153    
14154                    if (!getDB().isSupportsInlineDistinct()) {
14155                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14156                    }
14157    
14158                    if (orderByComparator != null) {
14159                            if (getDB().isSupportsInlineDistinct()) {
14160                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14161                                            orderByComparator, true);
14162                            }
14163                            else {
14164                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14165                                            orderByComparator, true);
14166                            }
14167                    }
14168                    else {
14169                            if (getDB().isSupportsInlineDistinct()) {
14170                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14171                            }
14172                            else {
14173                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14174                            }
14175                    }
14176    
14177                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14178                                    JournalArticle.class.getName(),
14179                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14180    
14181                    Session session = null;
14182    
14183                    try {
14184                            session = openSession();
14185    
14186                            SQLQuery q = session.createSQLQuery(sql);
14187    
14188                            if (getDB().isSupportsInlineDistinct()) {
14189                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14190                            }
14191                            else {
14192                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14193                            }
14194    
14195                            QueryPos qPos = QueryPos.getInstance(q);
14196    
14197                            qPos.add(groupId);
14198    
14199                            qPos.add(status);
14200    
14201                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14202                                    end);
14203                    }
14204                    catch (Exception e) {
14205                            throw processException(e);
14206                    }
14207                    finally {
14208                            closeSession(session);
14209                    }
14210            }
14211    
14212            /**
14213             * 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;.
14214             *
14215             * @param id the primary key of the current journal article
14216             * @param groupId the group ID
14217             * @param status the status
14218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14219             * @return the previous, current, and next journal article
14220             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14221             * @throws SystemException if a system exception occurred
14222             */
14223            @Override
14224            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
14225                    int status, OrderByComparator orderByComparator)
14226                    throws NoSuchArticleException, SystemException {
14227                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14228                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
14229                    }
14230    
14231                    JournalArticle journalArticle = findByPrimaryKey(id);
14232    
14233                    Session session = null;
14234    
14235                    try {
14236                            session = openSession();
14237    
14238                            JournalArticle[] array = new JournalArticleImpl[3];
14239    
14240                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14241                                            groupId, status, orderByComparator, true);
14242    
14243                            array[1] = journalArticle;
14244    
14245                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14246                                            groupId, status, orderByComparator, false);
14247    
14248                            return array;
14249                    }
14250                    catch (Exception e) {
14251                            throw processException(e);
14252                    }
14253                    finally {
14254                            closeSession(session);
14255                    }
14256            }
14257    
14258            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
14259                    JournalArticle journalArticle, long groupId, int status,
14260                    OrderByComparator orderByComparator, boolean previous) {
14261                    StringBundler query = null;
14262    
14263                    if (orderByComparator != null) {
14264                            query = new StringBundler(6 +
14265                                            (orderByComparator.getOrderByFields().length * 6));
14266                    }
14267                    else {
14268                            query = new StringBundler(3);
14269                    }
14270    
14271                    if (getDB().isSupportsInlineDistinct()) {
14272                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14273                    }
14274                    else {
14275                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14276                    }
14277    
14278                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14279    
14280                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14281    
14282                    if (!getDB().isSupportsInlineDistinct()) {
14283                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14284                    }
14285    
14286                    if (orderByComparator != null) {
14287                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14288    
14289                            if (orderByConditionFields.length > 0) {
14290                                    query.append(WHERE_AND);
14291                            }
14292    
14293                            for (int i = 0; i < orderByConditionFields.length; i++) {
14294                                    if (getDB().isSupportsInlineDistinct()) {
14295                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14296                                    }
14297                                    else {
14298                                            query.append(_ORDER_BY_ENTITY_TABLE);
14299                                    }
14300    
14301                                    query.append(orderByConditionFields[i]);
14302    
14303                                    if ((i + 1) < orderByConditionFields.length) {
14304                                            if (orderByComparator.isAscending() ^ previous) {
14305                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14306                                            }
14307                                            else {
14308                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14309                                            }
14310                                    }
14311                                    else {
14312                                            if (orderByComparator.isAscending() ^ previous) {
14313                                                    query.append(WHERE_GREATER_THAN);
14314                                            }
14315                                            else {
14316                                                    query.append(WHERE_LESSER_THAN);
14317                                            }
14318                                    }
14319                            }
14320    
14321                            query.append(ORDER_BY_CLAUSE);
14322    
14323                            String[] orderByFields = orderByComparator.getOrderByFields();
14324    
14325                            for (int i = 0; i < orderByFields.length; i++) {
14326                                    if (getDB().isSupportsInlineDistinct()) {
14327                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14328                                    }
14329                                    else {
14330                                            query.append(_ORDER_BY_ENTITY_TABLE);
14331                                    }
14332    
14333                                    query.append(orderByFields[i]);
14334    
14335                                    if ((i + 1) < orderByFields.length) {
14336                                            if (orderByComparator.isAscending() ^ previous) {
14337                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14338                                            }
14339                                            else {
14340                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14341                                            }
14342                                    }
14343                                    else {
14344                                            if (orderByComparator.isAscending() ^ previous) {
14345                                                    query.append(ORDER_BY_ASC);
14346                                            }
14347                                            else {
14348                                                    query.append(ORDER_BY_DESC);
14349                                            }
14350                                    }
14351                            }
14352                    }
14353                    else {
14354                            if (getDB().isSupportsInlineDistinct()) {
14355                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14356                            }
14357                            else {
14358                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14359                            }
14360                    }
14361    
14362                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14363                                    JournalArticle.class.getName(),
14364                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14365    
14366                    SQLQuery q = session.createSQLQuery(sql);
14367    
14368                    q.setFirstResult(0);
14369                    q.setMaxResults(2);
14370    
14371                    if (getDB().isSupportsInlineDistinct()) {
14372                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14373                    }
14374                    else {
14375                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14376                    }
14377    
14378                    QueryPos qPos = QueryPos.getInstance(q);
14379    
14380                    qPos.add(groupId);
14381    
14382                    qPos.add(status);
14383    
14384                    if (orderByComparator != null) {
14385                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14386    
14387                            for (Object value : values) {
14388                                    qPos.add(value);
14389                            }
14390                    }
14391    
14392                    List<JournalArticle> list = q.list();
14393    
14394                    if (list.size() == 2) {
14395                            return list.get(1);
14396                    }
14397                    else {
14398                            return null;
14399                    }
14400            }
14401    
14402            /**
14403             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14404             *
14405             * @param groupId the group ID
14406             * @param status the status
14407             * @throws SystemException if a system exception occurred
14408             */
14409            @Override
14410            public void removeByG_ST(long groupId, int status)
14411                    throws SystemException {
14412                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
14413                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14414                            remove(journalArticle);
14415                    }
14416            }
14417    
14418            /**
14419             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
14420             *
14421             * @param groupId the group ID
14422             * @param status the status
14423             * @return the number of matching journal articles
14424             * @throws SystemException if a system exception occurred
14425             */
14426            @Override
14427            public int countByG_ST(long groupId, int status) throws SystemException {
14428                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
14429    
14430                    Object[] finderArgs = new Object[] { groupId, status };
14431    
14432                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14433                                    this);
14434    
14435                    if (count == null) {
14436                            StringBundler query = new StringBundler(3);
14437    
14438                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14439    
14440                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14441    
14442                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14443    
14444                            String sql = query.toString();
14445    
14446                            Session session = null;
14447    
14448                            try {
14449                                    session = openSession();
14450    
14451                                    Query q = session.createQuery(sql);
14452    
14453                                    QueryPos qPos = QueryPos.getInstance(q);
14454    
14455                                    qPos.add(groupId);
14456    
14457                                    qPos.add(status);
14458    
14459                                    count = (Long)q.uniqueResult();
14460    
14461                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14462                            }
14463                            catch (Exception e) {
14464                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14465    
14466                                    throw processException(e);
14467                            }
14468                            finally {
14469                                    closeSession(session);
14470                            }
14471                    }
14472    
14473                    return count.intValue();
14474            }
14475    
14476            /**
14477             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14478             *
14479             * @param groupId the group ID
14480             * @param status the status
14481             * @return the number of matching journal articles that the user has permission to view
14482             * @throws SystemException if a system exception occurred
14483             */
14484            @Override
14485            public int filterCountByG_ST(long groupId, int status)
14486                    throws SystemException {
14487                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14488                            return countByG_ST(groupId, status);
14489                    }
14490    
14491                    StringBundler query = new StringBundler(3);
14492    
14493                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14494    
14495                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14496    
14497                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14498    
14499                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14500                                    JournalArticle.class.getName(),
14501                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14502    
14503                    Session session = null;
14504    
14505                    try {
14506                            session = openSession();
14507    
14508                            SQLQuery q = session.createSQLQuery(sql);
14509    
14510                            q.addScalar(COUNT_COLUMN_NAME,
14511                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14512    
14513                            QueryPos qPos = QueryPos.getInstance(q);
14514    
14515                            qPos.add(groupId);
14516    
14517                            qPos.add(status);
14518    
14519                            Long count = (Long)q.uniqueResult();
14520    
14521                            return count.intValue();
14522                    }
14523                    catch (Exception e) {
14524                            throw processException(e);
14525                    }
14526                    finally {
14527                            closeSession(session);
14528                    }
14529            }
14530    
14531            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
14532            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
14533            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14534                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14535                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14536                            "findByC_V",
14537                            new String[] {
14538                                    Long.class.getName(), Double.class.getName(),
14539                                    
14540                            Integer.class.getName(), Integer.class.getName(),
14541                                    OrderByComparator.class.getName()
14542                            });
14543            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14544                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14545                            JournalArticleImpl.class,
14546                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
14547                            new String[] { Long.class.getName(), Double.class.getName() },
14548                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
14549                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
14550                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
14551            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14552                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14553                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
14554                            new String[] { Long.class.getName(), Double.class.getName() });
14555    
14556            /**
14557             * Returns all the journal articles where companyId = &#63; and version = &#63;.
14558             *
14559             * @param companyId the company ID
14560             * @param version the version
14561             * @return the matching journal articles
14562             * @throws SystemException if a system exception occurred
14563             */
14564            @Override
14565            public List<JournalArticle> findByC_V(long companyId, double version)
14566                    throws SystemException {
14567                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
14568                            QueryUtil.ALL_POS, null);
14569            }
14570    
14571            /**
14572             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
14573             *
14574             * <p>
14575             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14576             * </p>
14577             *
14578             * @param companyId the company ID
14579             * @param version the version
14580             * @param start the lower bound of the range of journal articles
14581             * @param end the upper bound of the range of journal articles (not inclusive)
14582             * @return the range of matching journal articles
14583             * @throws SystemException if a system exception occurred
14584             */
14585            @Override
14586            public List<JournalArticle> findByC_V(long companyId, double version,
14587                    int start, int end) throws SystemException {
14588                    return findByC_V(companyId, version, start, end, null);
14589            }
14590    
14591            /**
14592             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
14593             *
14594             * <p>
14595             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14596             * </p>
14597             *
14598             * @param companyId the company ID
14599             * @param version the version
14600             * @param start the lower bound of the range of journal articles
14601             * @param end the upper bound of the range of journal articles (not inclusive)
14602             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14603             * @return the ordered range of matching journal articles
14604             * @throws SystemException if a system exception occurred
14605             */
14606            @Override
14607            public List<JournalArticle> findByC_V(long companyId, double version,
14608                    int start, int end, OrderByComparator orderByComparator)
14609                    throws SystemException {
14610                    boolean pagination = true;
14611                    FinderPath finderPath = null;
14612                    Object[] finderArgs = null;
14613    
14614                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14615                                    (orderByComparator == null)) {
14616                            pagination = false;
14617                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
14618                            finderArgs = new Object[] { companyId, version };
14619                    }
14620                    else {
14621                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
14622                            finderArgs = new Object[] {
14623                                            companyId, version,
14624                                            
14625                                            start, end, orderByComparator
14626                                    };
14627                    }
14628    
14629                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14630                                    finderArgs, this);
14631    
14632                    if ((list != null) && !list.isEmpty()) {
14633                            for (JournalArticle journalArticle : list) {
14634                                    if ((companyId != journalArticle.getCompanyId()) ||
14635                                                    (version != journalArticle.getVersion())) {
14636                                            list = null;
14637    
14638                                            break;
14639                                    }
14640                            }
14641                    }
14642    
14643                    if (list == null) {
14644                            StringBundler query = null;
14645    
14646                            if (orderByComparator != null) {
14647                                    query = new StringBundler(4 +
14648                                                    (orderByComparator.getOrderByFields().length * 3));
14649                            }
14650                            else {
14651                                    query = new StringBundler(4);
14652                            }
14653    
14654                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14655    
14656                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14657    
14658                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
14659    
14660                            if (orderByComparator != null) {
14661                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14662                                            orderByComparator);
14663                            }
14664                            else
14665                             if (pagination) {
14666                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14667                            }
14668    
14669                            String sql = query.toString();
14670    
14671                            Session session = null;
14672    
14673                            try {
14674                                    session = openSession();
14675    
14676                                    Query q = session.createQuery(sql);
14677    
14678                                    QueryPos qPos = QueryPos.getInstance(q);
14679    
14680                                    qPos.add(companyId);
14681    
14682                                    qPos.add(version);
14683    
14684                                    if (!pagination) {
14685                                            list = (List<JournalArticle>)QueryUtil.list(q,
14686                                                            getDialect(), start, end, false);
14687    
14688                                            Collections.sort(list);
14689    
14690                                            list = new UnmodifiableList<JournalArticle>(list);
14691                                    }
14692                                    else {
14693                                            list = (List<JournalArticle>)QueryUtil.list(q,
14694                                                            getDialect(), start, end);
14695                                    }
14696    
14697                                    cacheResult(list);
14698    
14699                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14700                            }
14701                            catch (Exception e) {
14702                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14703    
14704                                    throw processException(e);
14705                            }
14706                            finally {
14707                                    closeSession(session);
14708                            }
14709                    }
14710    
14711                    return list;
14712            }
14713    
14714            /**
14715             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14716             *
14717             * @param companyId the company ID
14718             * @param version the version
14719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14720             * @return the first matching journal article
14721             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14722             * @throws SystemException if a system exception occurred
14723             */
14724            @Override
14725            public JournalArticle findByC_V_First(long companyId, double version,
14726                    OrderByComparator orderByComparator)
14727                    throws NoSuchArticleException, SystemException {
14728                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
14729                                    orderByComparator);
14730    
14731                    if (journalArticle != null) {
14732                            return journalArticle;
14733                    }
14734    
14735                    StringBundler msg = new StringBundler(6);
14736    
14737                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14738    
14739                    msg.append("companyId=");
14740                    msg.append(companyId);
14741    
14742                    msg.append(", version=");
14743                    msg.append(version);
14744    
14745                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14746    
14747                    throw new NoSuchArticleException(msg.toString());
14748            }
14749    
14750            /**
14751             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14752             *
14753             * @param companyId the company ID
14754             * @param version the version
14755             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14756             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14757             * @throws SystemException if a system exception occurred
14758             */
14759            @Override
14760            public JournalArticle fetchByC_V_First(long companyId, double version,
14761                    OrderByComparator orderByComparator) throws SystemException {
14762                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
14763                                    orderByComparator);
14764    
14765                    if (!list.isEmpty()) {
14766                            return list.get(0);
14767                    }
14768    
14769                    return null;
14770            }
14771    
14772            /**
14773             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14774             *
14775             * @param companyId the company ID
14776             * @param version the version
14777             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14778             * @return the last matching journal article
14779             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14780             * @throws SystemException if a system exception occurred
14781             */
14782            @Override
14783            public JournalArticle findByC_V_Last(long companyId, double version,
14784                    OrderByComparator orderByComparator)
14785                    throws NoSuchArticleException, SystemException {
14786                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
14787                                    orderByComparator);
14788    
14789                    if (journalArticle != null) {
14790                            return journalArticle;
14791                    }
14792    
14793                    StringBundler msg = new StringBundler(6);
14794    
14795                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14796    
14797                    msg.append("companyId=");
14798                    msg.append(companyId);
14799    
14800                    msg.append(", version=");
14801                    msg.append(version);
14802    
14803                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14804    
14805                    throw new NoSuchArticleException(msg.toString());
14806            }
14807    
14808            /**
14809             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14810             *
14811             * @param companyId the company ID
14812             * @param version the version
14813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14814             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14815             * @throws SystemException if a system exception occurred
14816             */
14817            @Override
14818            public JournalArticle fetchByC_V_Last(long companyId, double version,
14819                    OrderByComparator orderByComparator) throws SystemException {
14820                    int count = countByC_V(companyId, version);
14821    
14822                    if (count == 0) {
14823                            return null;
14824                    }
14825    
14826                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
14827                                    count, orderByComparator);
14828    
14829                    if (!list.isEmpty()) {
14830                            return list.get(0);
14831                    }
14832    
14833                    return null;
14834            }
14835    
14836            /**
14837             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
14838             *
14839             * @param id the primary key of the current journal article
14840             * @param companyId the company ID
14841             * @param version the version
14842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14843             * @return the previous, current, and next journal article
14844             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14845             * @throws SystemException if a system exception occurred
14846             */
14847            @Override
14848            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
14849                    double version, OrderByComparator orderByComparator)
14850                    throws NoSuchArticleException, SystemException {
14851                    JournalArticle journalArticle = findByPrimaryKey(id);
14852    
14853                    Session session = null;
14854    
14855                    try {
14856                            session = openSession();
14857    
14858                            JournalArticle[] array = new JournalArticleImpl[3];
14859    
14860                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14861                                            version, orderByComparator, true);
14862    
14863                            array[1] = journalArticle;
14864    
14865                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14866                                            version, orderByComparator, false);
14867    
14868                            return array;
14869                    }
14870                    catch (Exception e) {
14871                            throw processException(e);
14872                    }
14873                    finally {
14874                            closeSession(session);
14875                    }
14876            }
14877    
14878            protected JournalArticle getByC_V_PrevAndNext(Session session,
14879                    JournalArticle journalArticle, long companyId, double version,
14880                    OrderByComparator orderByComparator, boolean previous) {
14881                    StringBundler query = null;
14882    
14883                    if (orderByComparator != null) {
14884                            query = new StringBundler(6 +
14885                                            (orderByComparator.getOrderByFields().length * 6));
14886                    }
14887                    else {
14888                            query = new StringBundler(3);
14889                    }
14890    
14891                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14892    
14893                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14894    
14895                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
14896    
14897                    if (orderByComparator != null) {
14898                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14899    
14900                            if (orderByConditionFields.length > 0) {
14901                                    query.append(WHERE_AND);
14902                            }
14903    
14904                            for (int i = 0; i < orderByConditionFields.length; i++) {
14905                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14906                                    query.append(orderByConditionFields[i]);
14907    
14908                                    if ((i + 1) < orderByConditionFields.length) {
14909                                            if (orderByComparator.isAscending() ^ previous) {
14910                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14911                                            }
14912                                            else {
14913                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14914                                            }
14915                                    }
14916                                    else {
14917                                            if (orderByComparator.isAscending() ^ previous) {
14918                                                    query.append(WHERE_GREATER_THAN);
14919                                            }
14920                                            else {
14921                                                    query.append(WHERE_LESSER_THAN);
14922                                            }
14923                                    }
14924                            }
14925    
14926                            query.append(ORDER_BY_CLAUSE);
14927    
14928                            String[] orderByFields = orderByComparator.getOrderByFields();
14929    
14930                            for (int i = 0; i < orderByFields.length; i++) {
14931                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14932                                    query.append(orderByFields[i]);
14933    
14934                                    if ((i + 1) < orderByFields.length) {
14935                                            if (orderByComparator.isAscending() ^ previous) {
14936                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14937                                            }
14938                                            else {
14939                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14940                                            }
14941                                    }
14942                                    else {
14943                                            if (orderByComparator.isAscending() ^ previous) {
14944                                                    query.append(ORDER_BY_ASC);
14945                                            }
14946                                            else {
14947                                                    query.append(ORDER_BY_DESC);
14948                                            }
14949                                    }
14950                            }
14951                    }
14952                    else {
14953                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14954                    }
14955    
14956                    String sql = query.toString();
14957    
14958                    Query q = session.createQuery(sql);
14959    
14960                    q.setFirstResult(0);
14961                    q.setMaxResults(2);
14962    
14963                    QueryPos qPos = QueryPos.getInstance(q);
14964    
14965                    qPos.add(companyId);
14966    
14967                    qPos.add(version);
14968    
14969                    if (orderByComparator != null) {
14970                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14971    
14972                            for (Object value : values) {
14973                                    qPos.add(value);
14974                            }
14975                    }
14976    
14977                    List<JournalArticle> list = q.list();
14978    
14979                    if (list.size() == 2) {
14980                            return list.get(1);
14981                    }
14982                    else {
14983                            return null;
14984                    }
14985            }
14986    
14987            /**
14988             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
14989             *
14990             * @param companyId the company ID
14991             * @param version the version
14992             * @throws SystemException if a system exception occurred
14993             */
14994            @Override
14995            public void removeByC_V(long companyId, double version)
14996                    throws SystemException {
14997                    for (JournalArticle journalArticle : findByC_V(companyId, version,
14998                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14999                            remove(journalArticle);
15000                    }
15001            }
15002    
15003            /**
15004             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15005             *
15006             * @param companyId the company ID
15007             * @param version the version
15008             * @return the number of matching journal articles
15009             * @throws SystemException if a system exception occurred
15010             */
15011            @Override
15012            public int countByC_V(long companyId, double version)
15013                    throws SystemException {
15014                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
15015    
15016                    Object[] finderArgs = new Object[] { companyId, version };
15017    
15018                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15019                                    this);
15020    
15021                    if (count == null) {
15022                            StringBundler query = new StringBundler(3);
15023    
15024                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15025    
15026                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15027    
15028                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15029    
15030                            String sql = query.toString();
15031    
15032                            Session session = null;
15033    
15034                            try {
15035                                    session = openSession();
15036    
15037                                    Query q = session.createQuery(sql);
15038    
15039                                    QueryPos qPos = QueryPos.getInstance(q);
15040    
15041                                    qPos.add(companyId);
15042    
15043                                    qPos.add(version);
15044    
15045                                    count = (Long)q.uniqueResult();
15046    
15047                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15048                            }
15049                            catch (Exception e) {
15050                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15051    
15052                                    throw processException(e);
15053                            }
15054                            finally {
15055                                    closeSession(session);
15056                            }
15057                    }
15058    
15059                    return count.intValue();
15060            }
15061    
15062            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15063            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
15064            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15065                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15066                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15067                            "findByC_ST",
15068                            new String[] {
15069                                    Long.class.getName(), Integer.class.getName(),
15070                                    
15071                            Integer.class.getName(), Integer.class.getName(),
15072                                    OrderByComparator.class.getName()
15073                            });
15074            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15075                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15076                            JournalArticleImpl.class,
15077                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
15078                            new String[] { Long.class.getName(), Integer.class.getName() },
15079                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15080                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
15081                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
15082                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
15083            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15084                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15085                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
15086                            new String[] { Long.class.getName(), Integer.class.getName() });
15087    
15088            /**
15089             * Returns all the journal articles where companyId = &#63; and status = &#63;.
15090             *
15091             * @param companyId the company ID
15092             * @param status the status
15093             * @return the matching journal articles
15094             * @throws SystemException if a system exception occurred
15095             */
15096            @Override
15097            public List<JournalArticle> findByC_ST(long companyId, int status)
15098                    throws SystemException {
15099                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
15100                            QueryUtil.ALL_POS, null);
15101            }
15102    
15103            /**
15104             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
15105             *
15106             * <p>
15107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15108             * </p>
15109             *
15110             * @param companyId the company ID
15111             * @param status the status
15112             * @param start the lower bound of the range of journal articles
15113             * @param end the upper bound of the range of journal articles (not inclusive)
15114             * @return the range of matching journal articles
15115             * @throws SystemException if a system exception occurred
15116             */
15117            @Override
15118            public List<JournalArticle> findByC_ST(long companyId, int status,
15119                    int start, int end) throws SystemException {
15120                    return findByC_ST(companyId, status, start, end, null);
15121            }
15122    
15123            /**
15124             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
15125             *
15126             * <p>
15127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15128             * </p>
15129             *
15130             * @param companyId the company ID
15131             * @param status the status
15132             * @param start the lower bound of the range of journal articles
15133             * @param end the upper bound of the range of journal articles (not inclusive)
15134             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15135             * @return the ordered range of matching journal articles
15136             * @throws SystemException if a system exception occurred
15137             */
15138            @Override
15139            public List<JournalArticle> findByC_ST(long companyId, int status,
15140                    int start, int end, OrderByComparator orderByComparator)
15141                    throws SystemException {
15142                    boolean pagination = true;
15143                    FinderPath finderPath = null;
15144                    Object[] finderArgs = null;
15145    
15146                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15147                                    (orderByComparator == null)) {
15148                            pagination = false;
15149                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
15150                            finderArgs = new Object[] { companyId, status };
15151                    }
15152                    else {
15153                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
15154                            finderArgs = new Object[] {
15155                                            companyId, status,
15156                                            
15157                                            start, end, orderByComparator
15158                                    };
15159                    }
15160    
15161                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15162                                    finderArgs, this);
15163    
15164                    if ((list != null) && !list.isEmpty()) {
15165                            for (JournalArticle journalArticle : list) {
15166                                    if ((companyId != journalArticle.getCompanyId()) ||
15167                                                    (status != journalArticle.getStatus())) {
15168                                            list = null;
15169    
15170                                            break;
15171                                    }
15172                            }
15173                    }
15174    
15175                    if (list == null) {
15176                            StringBundler query = null;
15177    
15178                            if (orderByComparator != null) {
15179                                    query = new StringBundler(4 +
15180                                                    (orderByComparator.getOrderByFields().length * 3));
15181                            }
15182                            else {
15183                                    query = new StringBundler(4);
15184                            }
15185    
15186                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15187    
15188                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15189    
15190                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15191    
15192                            if (orderByComparator != null) {
15193                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15194                                            orderByComparator);
15195                            }
15196                            else
15197                             if (pagination) {
15198                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15199                            }
15200    
15201                            String sql = query.toString();
15202    
15203                            Session session = null;
15204    
15205                            try {
15206                                    session = openSession();
15207    
15208                                    Query q = session.createQuery(sql);
15209    
15210                                    QueryPos qPos = QueryPos.getInstance(q);
15211    
15212                                    qPos.add(companyId);
15213    
15214                                    qPos.add(status);
15215    
15216                                    if (!pagination) {
15217                                            list = (List<JournalArticle>)QueryUtil.list(q,
15218                                                            getDialect(), start, end, false);
15219    
15220                                            Collections.sort(list);
15221    
15222                                            list = new UnmodifiableList<JournalArticle>(list);
15223                                    }
15224                                    else {
15225                                            list = (List<JournalArticle>)QueryUtil.list(q,
15226                                                            getDialect(), start, end);
15227                                    }
15228    
15229                                    cacheResult(list);
15230    
15231                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15232                            }
15233                            catch (Exception e) {
15234                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15235    
15236                                    throw processException(e);
15237                            }
15238                            finally {
15239                                    closeSession(session);
15240                            }
15241                    }
15242    
15243                    return list;
15244            }
15245    
15246            /**
15247             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15248             *
15249             * @param companyId the company ID
15250             * @param status the status
15251             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15252             * @return the first matching journal article
15253             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15254             * @throws SystemException if a system exception occurred
15255             */
15256            @Override
15257            public JournalArticle findByC_ST_First(long companyId, int status,
15258                    OrderByComparator orderByComparator)
15259                    throws NoSuchArticleException, SystemException {
15260                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
15261                                    orderByComparator);
15262    
15263                    if (journalArticle != null) {
15264                            return journalArticle;
15265                    }
15266    
15267                    StringBundler msg = new StringBundler(6);
15268    
15269                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15270    
15271                    msg.append("companyId=");
15272                    msg.append(companyId);
15273    
15274                    msg.append(", status=");
15275                    msg.append(status);
15276    
15277                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15278    
15279                    throw new NoSuchArticleException(msg.toString());
15280            }
15281    
15282            /**
15283             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15284             *
15285             * @param companyId the company ID
15286             * @param status the status
15287             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15288             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15289             * @throws SystemException if a system exception occurred
15290             */
15291            @Override
15292            public JournalArticle fetchByC_ST_First(long companyId, int status,
15293                    OrderByComparator orderByComparator) throws SystemException {
15294                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
15295                                    orderByComparator);
15296    
15297                    if (!list.isEmpty()) {
15298                            return list.get(0);
15299                    }
15300    
15301                    return null;
15302            }
15303    
15304            /**
15305             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15306             *
15307             * @param companyId the company ID
15308             * @param status the status
15309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15310             * @return the last matching journal article
15311             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15312             * @throws SystemException if a system exception occurred
15313             */
15314            @Override
15315            public JournalArticle findByC_ST_Last(long companyId, int status,
15316                    OrderByComparator orderByComparator)
15317                    throws NoSuchArticleException, SystemException {
15318                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
15319                                    orderByComparator);
15320    
15321                    if (journalArticle != null) {
15322                            return journalArticle;
15323                    }
15324    
15325                    StringBundler msg = new StringBundler(6);
15326    
15327                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15328    
15329                    msg.append("companyId=");
15330                    msg.append(companyId);
15331    
15332                    msg.append(", status=");
15333                    msg.append(status);
15334    
15335                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15336    
15337                    throw new NoSuchArticleException(msg.toString());
15338            }
15339    
15340            /**
15341             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15342             *
15343             * @param companyId the company ID
15344             * @param status the status
15345             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15346             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15347             * @throws SystemException if a system exception occurred
15348             */
15349            @Override
15350            public JournalArticle fetchByC_ST_Last(long companyId, int status,
15351                    OrderByComparator orderByComparator) throws SystemException {
15352                    int count = countByC_ST(companyId, status);
15353    
15354                    if (count == 0) {
15355                            return null;
15356                    }
15357    
15358                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
15359                                    count, orderByComparator);
15360    
15361                    if (!list.isEmpty()) {
15362                            return list.get(0);
15363                    }
15364    
15365                    return null;
15366            }
15367    
15368            /**
15369             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
15370             *
15371             * @param id the primary key of the current journal article
15372             * @param companyId the company ID
15373             * @param status the status
15374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15375             * @return the previous, current, and next journal article
15376             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15377             * @throws SystemException if a system exception occurred
15378             */
15379            @Override
15380            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
15381                    int status, OrderByComparator orderByComparator)
15382                    throws NoSuchArticleException, SystemException {
15383                    JournalArticle journalArticle = findByPrimaryKey(id);
15384    
15385                    Session session = null;
15386    
15387                    try {
15388                            session = openSession();
15389    
15390                            JournalArticle[] array = new JournalArticleImpl[3];
15391    
15392                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
15393                                            companyId, status, orderByComparator, true);
15394    
15395                            array[1] = journalArticle;
15396    
15397                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
15398                                            companyId, status, orderByComparator, false);
15399    
15400                            return array;
15401                    }
15402                    catch (Exception e) {
15403                            throw processException(e);
15404                    }
15405                    finally {
15406                            closeSession(session);
15407                    }
15408            }
15409    
15410            protected JournalArticle getByC_ST_PrevAndNext(Session session,
15411                    JournalArticle journalArticle, long companyId, int status,
15412                    OrderByComparator orderByComparator, boolean previous) {
15413                    StringBundler query = null;
15414    
15415                    if (orderByComparator != null) {
15416                            query = new StringBundler(6 +
15417                                            (orderByComparator.getOrderByFields().length * 6));
15418                    }
15419                    else {
15420                            query = new StringBundler(3);
15421                    }
15422    
15423                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15424    
15425                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15426    
15427                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15428    
15429                    if (orderByComparator != null) {
15430                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15431    
15432                            if (orderByConditionFields.length > 0) {
15433                                    query.append(WHERE_AND);
15434                            }
15435    
15436                            for (int i = 0; i < orderByConditionFields.length; i++) {
15437                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15438                                    query.append(orderByConditionFields[i]);
15439    
15440                                    if ((i + 1) < orderByConditionFields.length) {
15441                                            if (orderByComparator.isAscending() ^ previous) {
15442                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15443                                            }
15444                                            else {
15445                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15446                                            }
15447                                    }
15448                                    else {
15449                                            if (orderByComparator.isAscending() ^ previous) {
15450                                                    query.append(WHERE_GREATER_THAN);
15451                                            }
15452                                            else {
15453                                                    query.append(WHERE_LESSER_THAN);
15454                                            }
15455                                    }
15456                            }
15457    
15458                            query.append(ORDER_BY_CLAUSE);
15459    
15460                            String[] orderByFields = orderByComparator.getOrderByFields();
15461    
15462                            for (int i = 0; i < orderByFields.length; i++) {
15463                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15464                                    query.append(orderByFields[i]);
15465    
15466                                    if ((i + 1) < orderByFields.length) {
15467                                            if (orderByComparator.isAscending() ^ previous) {
15468                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15469                                            }
15470                                            else {
15471                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15472                                            }
15473                                    }
15474                                    else {
15475                                            if (orderByComparator.isAscending() ^ previous) {
15476                                                    query.append(ORDER_BY_ASC);
15477                                            }
15478                                            else {
15479                                                    query.append(ORDER_BY_DESC);
15480                                            }
15481                                    }
15482                            }
15483                    }
15484                    else {
15485                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15486                    }
15487    
15488                    String sql = query.toString();
15489    
15490                    Query q = session.createQuery(sql);
15491    
15492                    q.setFirstResult(0);
15493                    q.setMaxResults(2);
15494    
15495                    QueryPos qPos = QueryPos.getInstance(q);
15496    
15497                    qPos.add(companyId);
15498    
15499                    qPos.add(status);
15500    
15501                    if (orderByComparator != null) {
15502                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15503    
15504                            for (Object value : values) {
15505                                    qPos.add(value);
15506                            }
15507                    }
15508    
15509                    List<JournalArticle> list = q.list();
15510    
15511                    if (list.size() == 2) {
15512                            return list.get(1);
15513                    }
15514                    else {
15515                            return null;
15516                    }
15517            }
15518    
15519            /**
15520             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
15521             *
15522             * @param companyId the company ID
15523             * @param status the status
15524             * @throws SystemException if a system exception occurred
15525             */
15526            @Override
15527            public void removeByC_ST(long companyId, int status)
15528                    throws SystemException {
15529                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
15530                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15531                            remove(journalArticle);
15532                    }
15533            }
15534    
15535            /**
15536             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
15537             *
15538             * @param companyId the company ID
15539             * @param status the status
15540             * @return the number of matching journal articles
15541             * @throws SystemException if a system exception occurred
15542             */
15543            @Override
15544            public int countByC_ST(long companyId, int status)
15545                    throws SystemException {
15546                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
15547    
15548                    Object[] finderArgs = new Object[] { companyId, status };
15549    
15550                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15551                                    this);
15552    
15553                    if (count == null) {
15554                            StringBundler query = new StringBundler(3);
15555    
15556                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15557    
15558                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15559    
15560                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15561    
15562                            String sql = query.toString();
15563    
15564                            Session session = null;
15565    
15566                            try {
15567                                    session = openSession();
15568    
15569                                    Query q = session.createQuery(sql);
15570    
15571                                    QueryPos qPos = QueryPos.getInstance(q);
15572    
15573                                    qPos.add(companyId);
15574    
15575                                    qPos.add(status);
15576    
15577                                    count = (Long)q.uniqueResult();
15578    
15579                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15580                            }
15581                            catch (Exception e) {
15582                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15583    
15584                                    throw processException(e);
15585                            }
15586                            finally {
15587                                    closeSession(session);
15588                            }
15589                    }
15590    
15591                    return count.intValue();
15592            }
15593    
15594            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15595            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
15596            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15597                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15598                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15599                            "findByC_NotST",
15600                            new String[] {
15601                                    Long.class.getName(), Integer.class.getName(),
15602                                    
15603                            Integer.class.getName(), Integer.class.getName(),
15604                                    OrderByComparator.class.getName()
15605                            });
15606            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15607                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15608                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotST",
15609                            new String[] { Long.class.getName(), Integer.class.getName() });
15610    
15611            /**
15612             * Returns all the journal articles where companyId = &#63; and status &ne; &#63;.
15613             *
15614             * @param companyId the company ID
15615             * @param status the status
15616             * @return the matching journal articles
15617             * @throws SystemException if a system exception occurred
15618             */
15619            @Override
15620            public List<JournalArticle> findByC_NotST(long companyId, int status)
15621                    throws SystemException {
15622                    return findByC_NotST(companyId, status, QueryUtil.ALL_POS,
15623                            QueryUtil.ALL_POS, null);
15624            }
15625    
15626            /**
15627             * Returns a range of all the journal articles where companyId = &#63; and status &ne; &#63;.
15628             *
15629             * <p>
15630             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15631             * </p>
15632             *
15633             * @param companyId the company ID
15634             * @param status the status
15635             * @param start the lower bound of the range of journal articles
15636             * @param end the upper bound of the range of journal articles (not inclusive)
15637             * @return the range of matching journal articles
15638             * @throws SystemException if a system exception occurred
15639             */
15640            @Override
15641            public List<JournalArticle> findByC_NotST(long companyId, int status,
15642                    int start, int end) throws SystemException {
15643                    return findByC_NotST(companyId, status, start, end, null);
15644            }
15645    
15646            /**
15647             * Returns an ordered range of all the journal articles where companyId = &#63; and status &ne; &#63;.
15648             *
15649             * <p>
15650             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15651             * </p>
15652             *
15653             * @param companyId the company ID
15654             * @param status the status
15655             * @param start the lower bound of the range of journal articles
15656             * @param end the upper bound of the range of journal articles (not inclusive)
15657             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15658             * @return the ordered range of matching journal articles
15659             * @throws SystemException if a system exception occurred
15660             */
15661            @Override
15662            public List<JournalArticle> findByC_NotST(long companyId, int status,
15663                    int start, int end, OrderByComparator orderByComparator)
15664                    throws SystemException {
15665                    boolean pagination = true;
15666                    FinderPath finderPath = null;
15667                    Object[] finderArgs = null;
15668    
15669                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST;
15670                    finderArgs = new Object[] {
15671                                    companyId, status,
15672                                    
15673                                    start, end, orderByComparator
15674                            };
15675    
15676                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15677                                    finderArgs, this);
15678    
15679                    if ((list != null) && !list.isEmpty()) {
15680                            for (JournalArticle journalArticle : list) {
15681                                    if ((companyId != journalArticle.getCompanyId()) ||
15682                                                    (status != journalArticle.getStatus())) {
15683                                            list = null;
15684    
15685                                            break;
15686                                    }
15687                            }
15688                    }
15689    
15690                    if (list == null) {
15691                            StringBundler query = null;
15692    
15693                            if (orderByComparator != null) {
15694                                    query = new StringBundler(4 +
15695                                                    (orderByComparator.getOrderByFields().length * 3));
15696                            }
15697                            else {
15698                                    query = new StringBundler(4);
15699                            }
15700    
15701                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15702    
15703                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
15704    
15705                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
15706    
15707                            if (orderByComparator != null) {
15708                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15709                                            orderByComparator);
15710                            }
15711                            else
15712                             if (pagination) {
15713                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15714                            }
15715    
15716                            String sql = query.toString();
15717    
15718                            Session session = null;
15719    
15720                            try {
15721                                    session = openSession();
15722    
15723                                    Query q = session.createQuery(sql);
15724    
15725                                    QueryPos qPos = QueryPos.getInstance(q);
15726    
15727                                    qPos.add(companyId);
15728    
15729                                    qPos.add(status);
15730    
15731                                    if (!pagination) {
15732                                            list = (List<JournalArticle>)QueryUtil.list(q,
15733                                                            getDialect(), start, end, false);
15734    
15735                                            Collections.sort(list);
15736    
15737                                            list = new UnmodifiableList<JournalArticle>(list);
15738                                    }
15739                                    else {
15740                                            list = (List<JournalArticle>)QueryUtil.list(q,
15741                                                            getDialect(), start, end);
15742                                    }
15743    
15744                                    cacheResult(list);
15745    
15746                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15747                            }
15748                            catch (Exception e) {
15749                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15750    
15751                                    throw processException(e);
15752                            }
15753                            finally {
15754                                    closeSession(session);
15755                            }
15756                    }
15757    
15758                    return list;
15759            }
15760    
15761            /**
15762             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
15763             *
15764             * @param companyId the company ID
15765             * @param status the status
15766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15767             * @return the first matching journal article
15768             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15769             * @throws SystemException if a system exception occurred
15770             */
15771            @Override
15772            public JournalArticle findByC_NotST_First(long companyId, int status,
15773                    OrderByComparator orderByComparator)
15774                    throws NoSuchArticleException, SystemException {
15775                    JournalArticle journalArticle = fetchByC_NotST_First(companyId, status,
15776                                    orderByComparator);
15777    
15778                    if (journalArticle != null) {
15779                            return journalArticle;
15780                    }
15781    
15782                    StringBundler msg = new StringBundler(6);
15783    
15784                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15785    
15786                    msg.append("companyId=");
15787                    msg.append(companyId);
15788    
15789                    msg.append(", status=");
15790                    msg.append(status);
15791    
15792                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15793    
15794                    throw new NoSuchArticleException(msg.toString());
15795            }
15796    
15797            /**
15798             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
15799             *
15800             * @param companyId the company ID
15801             * @param status the status
15802             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15803             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15804             * @throws SystemException if a system exception occurred
15805             */
15806            @Override
15807            public JournalArticle fetchByC_NotST_First(long companyId, int status,
15808                    OrderByComparator orderByComparator) throws SystemException {
15809                    List<JournalArticle> list = findByC_NotST(companyId, status, 0, 1,
15810                                    orderByComparator);
15811    
15812                    if (!list.isEmpty()) {
15813                            return list.get(0);
15814                    }
15815    
15816                    return null;
15817            }
15818    
15819            /**
15820             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
15821             *
15822             * @param companyId the company ID
15823             * @param status the status
15824             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15825             * @return the last matching journal article
15826             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15827             * @throws SystemException if a system exception occurred
15828             */
15829            @Override
15830            public JournalArticle findByC_NotST_Last(long companyId, int status,
15831                    OrderByComparator orderByComparator)
15832                    throws NoSuchArticleException, SystemException {
15833                    JournalArticle journalArticle = fetchByC_NotST_Last(companyId, status,
15834                                    orderByComparator);
15835    
15836                    if (journalArticle != null) {
15837                            return journalArticle;
15838                    }
15839    
15840                    StringBundler msg = new StringBundler(6);
15841    
15842                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15843    
15844                    msg.append("companyId=");
15845                    msg.append(companyId);
15846    
15847                    msg.append(", status=");
15848                    msg.append(status);
15849    
15850                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15851    
15852                    throw new NoSuchArticleException(msg.toString());
15853            }
15854    
15855            /**
15856             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
15857             *
15858             * @param companyId the company ID
15859             * @param status the status
15860             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15861             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15862             * @throws SystemException if a system exception occurred
15863             */
15864            @Override
15865            public JournalArticle fetchByC_NotST_Last(long companyId, int status,
15866                    OrderByComparator orderByComparator) throws SystemException {
15867                    int count = countByC_NotST(companyId, status);
15868    
15869                    if (count == 0) {
15870                            return null;
15871                    }
15872    
15873                    List<JournalArticle> list = findByC_NotST(companyId, status, count - 1,
15874                                    count, orderByComparator);
15875    
15876                    if (!list.isEmpty()) {
15877                            return list.get(0);
15878                    }
15879    
15880                    return null;
15881            }
15882    
15883            /**
15884             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
15885             *
15886             * @param id the primary key of the current journal article
15887             * @param companyId the company ID
15888             * @param status the status
15889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15890             * @return the previous, current, and next journal article
15891             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15892             * @throws SystemException if a system exception occurred
15893             */
15894            @Override
15895            public JournalArticle[] findByC_NotST_PrevAndNext(long id, long companyId,
15896                    int status, OrderByComparator orderByComparator)
15897                    throws NoSuchArticleException, SystemException {
15898                    JournalArticle journalArticle = findByPrimaryKey(id);
15899    
15900                    Session session = null;
15901    
15902                    try {
15903                            session = openSession();
15904    
15905                            JournalArticle[] array = new JournalArticleImpl[3];
15906    
15907                            array[0] = getByC_NotST_PrevAndNext(session, journalArticle,
15908                                            companyId, status, orderByComparator, true);
15909    
15910                            array[1] = journalArticle;
15911    
15912                            array[2] = getByC_NotST_PrevAndNext(session, journalArticle,
15913                                            companyId, status, orderByComparator, false);
15914    
15915                            return array;
15916                    }
15917                    catch (Exception e) {
15918                            throw processException(e);
15919                    }
15920                    finally {
15921                            closeSession(session);
15922                    }
15923            }
15924    
15925            protected JournalArticle getByC_NotST_PrevAndNext(Session session,
15926                    JournalArticle journalArticle, long companyId, int status,
15927                    OrderByComparator orderByComparator, boolean previous) {
15928                    StringBundler query = null;
15929    
15930                    if (orderByComparator != null) {
15931                            query = new StringBundler(6 +
15932                                            (orderByComparator.getOrderByFields().length * 6));
15933                    }
15934                    else {
15935                            query = new StringBundler(3);
15936                    }
15937    
15938                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15939    
15940                    query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
15941    
15942                    query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
15943    
15944                    if (orderByComparator != null) {
15945                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15946    
15947                            if (orderByConditionFields.length > 0) {
15948                                    query.append(WHERE_AND);
15949                            }
15950    
15951                            for (int i = 0; i < orderByConditionFields.length; i++) {
15952                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15953                                    query.append(orderByConditionFields[i]);
15954    
15955                                    if ((i + 1) < orderByConditionFields.length) {
15956                                            if (orderByComparator.isAscending() ^ previous) {
15957                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15958                                            }
15959                                            else {
15960                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15961                                            }
15962                                    }
15963                                    else {
15964                                            if (orderByComparator.isAscending() ^ previous) {
15965                                                    query.append(WHERE_GREATER_THAN);
15966                                            }
15967                                            else {
15968                                                    query.append(WHERE_LESSER_THAN);
15969                                            }
15970                                    }
15971                            }
15972    
15973                            query.append(ORDER_BY_CLAUSE);
15974    
15975                            String[] orderByFields = orderByComparator.getOrderByFields();
15976    
15977                            for (int i = 0; i < orderByFields.length; i++) {
15978                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15979                                    query.append(orderByFields[i]);
15980    
15981                                    if ((i + 1) < orderByFields.length) {
15982                                            if (orderByComparator.isAscending() ^ previous) {
15983                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15984                                            }
15985                                            else {
15986                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15987                                            }
15988                                    }
15989                                    else {
15990                                            if (orderByComparator.isAscending() ^ previous) {
15991                                                    query.append(ORDER_BY_ASC);
15992                                            }
15993                                            else {
15994                                                    query.append(ORDER_BY_DESC);
15995                                            }
15996                                    }
15997                            }
15998                    }
15999                    else {
16000                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16001                    }
16002    
16003                    String sql = query.toString();
16004    
16005                    Query q = session.createQuery(sql);
16006    
16007                    q.setFirstResult(0);
16008                    q.setMaxResults(2);
16009    
16010                    QueryPos qPos = QueryPos.getInstance(q);
16011    
16012                    qPos.add(companyId);
16013    
16014                    qPos.add(status);
16015    
16016                    if (orderByComparator != null) {
16017                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16018    
16019                            for (Object value : values) {
16020                                    qPos.add(value);
16021                            }
16022                    }
16023    
16024                    List<JournalArticle> list = q.list();
16025    
16026                    if (list.size() == 2) {
16027                            return list.get(1);
16028                    }
16029                    else {
16030                            return null;
16031                    }
16032            }
16033    
16034            /**
16035             * Removes all the journal articles where companyId = &#63; and status &ne; &#63; from the database.
16036             *
16037             * @param companyId the company ID
16038             * @param status the status
16039             * @throws SystemException if a system exception occurred
16040             */
16041            @Override
16042            public void removeByC_NotST(long companyId, int status)
16043                    throws SystemException {
16044                    for (JournalArticle journalArticle : findByC_NotST(companyId, status,
16045                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16046                            remove(journalArticle);
16047                    }
16048            }
16049    
16050            /**
16051             * Returns the number of journal articles where companyId = &#63; and status &ne; &#63;.
16052             *
16053             * @param companyId the company ID
16054             * @param status the status
16055             * @return the number of matching journal articles
16056             * @throws SystemException if a system exception occurred
16057             */
16058            @Override
16059            public int countByC_NotST(long companyId, int status)
16060                    throws SystemException {
16061                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST;
16062    
16063                    Object[] finderArgs = new Object[] { companyId, status };
16064    
16065                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16066                                    this);
16067    
16068                    if (count == null) {
16069                            StringBundler query = new StringBundler(3);
16070    
16071                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16072    
16073                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16074    
16075                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16076    
16077                            String sql = query.toString();
16078    
16079                            Session session = null;
16080    
16081                            try {
16082                                    session = openSession();
16083    
16084                                    Query q = session.createQuery(sql);
16085    
16086                                    QueryPos qPos = QueryPos.getInstance(q);
16087    
16088                                    qPos.add(companyId);
16089    
16090                                    qPos.add(status);
16091    
16092                                    count = (Long)q.uniqueResult();
16093    
16094                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16095                            }
16096                            catch (Exception e) {
16097                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16098    
16099                                    throw processException(e);
16100                            }
16101                            finally {
16102                                    closeSession(session);
16103                            }
16104                    }
16105    
16106                    return count.intValue();
16107            }
16108    
16109            private static final String _FINDER_COLUMN_C_NOTST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16110            private static final String _FINDER_COLUMN_C_NOTST_STATUS_2 = "journalArticle.status != ?";
16111            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16112                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16113                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16114                            "findByLtD_S",
16115                            new String[] {
16116                                    Date.class.getName(), Integer.class.getName(),
16117                                    
16118                            Integer.class.getName(), Integer.class.getName(),
16119                                    OrderByComparator.class.getName()
16120                            });
16121            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16122                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16123                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
16124                            new String[] { Date.class.getName(), Integer.class.getName() });
16125    
16126            /**
16127             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
16128             *
16129             * @param displayDate the display date
16130             * @param status the status
16131             * @return the matching journal articles
16132             * @throws SystemException if a system exception occurred
16133             */
16134            @Override
16135            public List<JournalArticle> findByLtD_S(Date displayDate, int status)
16136                    throws SystemException {
16137                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
16138                            QueryUtil.ALL_POS, null);
16139            }
16140    
16141            /**
16142             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
16143             *
16144             * <p>
16145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16146             * </p>
16147             *
16148             * @param displayDate the display date
16149             * @param status the status
16150             * @param start the lower bound of the range of journal articles
16151             * @param end the upper bound of the range of journal articles (not inclusive)
16152             * @return the range of matching journal articles
16153             * @throws SystemException if a system exception occurred
16154             */
16155            @Override
16156            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
16157                    int start, int end) throws SystemException {
16158                    return findByLtD_S(displayDate, status, start, end, null);
16159            }
16160    
16161            /**
16162             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#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 displayDate the display date
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             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16173             * @return the ordered range of matching journal articles
16174             * @throws SystemException if a system exception occurred
16175             */
16176            @Override
16177            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
16178                    int start, int end, OrderByComparator orderByComparator)
16179                    throws SystemException {
16180                    boolean pagination = true;
16181                    FinderPath finderPath = null;
16182                    Object[] finderArgs = null;
16183    
16184                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
16185                    finderArgs = new Object[] {
16186                                    displayDate, status,
16187                                    
16188                                    start, end, orderByComparator
16189                            };
16190    
16191                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16192                                    finderArgs, this);
16193    
16194                    if ((list != null) && !list.isEmpty()) {
16195                            for (JournalArticle journalArticle : list) {
16196                                    if (!Validator.equals(displayDate,
16197                                                            journalArticle.getDisplayDate()) ||
16198                                                    (status != journalArticle.getStatus())) {
16199                                            list = null;
16200    
16201                                            break;
16202                                    }
16203                            }
16204                    }
16205    
16206                    if (list == null) {
16207                            StringBundler query = null;
16208    
16209                            if (orderByComparator != null) {
16210                                    query = new StringBundler(4 +
16211                                                    (orderByComparator.getOrderByFields().length * 3));
16212                            }
16213                            else {
16214                                    query = new StringBundler(4);
16215                            }
16216    
16217                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16218    
16219                            boolean bindDisplayDate = false;
16220    
16221                            if (displayDate == null) {
16222                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
16223                            }
16224                            else {
16225                                    bindDisplayDate = true;
16226    
16227                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
16228                            }
16229    
16230                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
16231    
16232                            if (orderByComparator != null) {
16233                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16234                                            orderByComparator);
16235                            }
16236                            else
16237                             if (pagination) {
16238                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16239                            }
16240    
16241                            String sql = query.toString();
16242    
16243                            Session session = null;
16244    
16245                            try {
16246                                    session = openSession();
16247    
16248                                    Query q = session.createQuery(sql);
16249    
16250                                    QueryPos qPos = QueryPos.getInstance(q);
16251    
16252                                    if (bindDisplayDate) {
16253                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16254                                    }
16255    
16256                                    qPos.add(status);
16257    
16258                                    if (!pagination) {
16259                                            list = (List<JournalArticle>)QueryUtil.list(q,
16260                                                            getDialect(), start, end, false);
16261    
16262                                            Collections.sort(list);
16263    
16264                                            list = new UnmodifiableList<JournalArticle>(list);
16265                                    }
16266                                    else {
16267                                            list = (List<JournalArticle>)QueryUtil.list(q,
16268                                                            getDialect(), start, end);
16269                                    }
16270    
16271                                    cacheResult(list);
16272    
16273                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16274                            }
16275                            catch (Exception e) {
16276                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16277    
16278                                    throw processException(e);
16279                            }
16280                            finally {
16281                                    closeSession(session);
16282                            }
16283                    }
16284    
16285                    return list;
16286            }
16287    
16288            /**
16289             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16290             *
16291             * @param displayDate the display date
16292             * @param status the status
16293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16294             * @return the first matching journal article
16295             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16296             * @throws SystemException if a system exception occurred
16297             */
16298            @Override
16299            public JournalArticle findByLtD_S_First(Date displayDate, int status,
16300                    OrderByComparator orderByComparator)
16301                    throws NoSuchArticleException, SystemException {
16302                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
16303                                    orderByComparator);
16304    
16305                    if (journalArticle != null) {
16306                            return journalArticle;
16307                    }
16308    
16309                    StringBundler msg = new StringBundler(6);
16310    
16311                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16312    
16313                    msg.append("displayDate=");
16314                    msg.append(displayDate);
16315    
16316                    msg.append(", status=");
16317                    msg.append(status);
16318    
16319                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16320    
16321                    throw new NoSuchArticleException(msg.toString());
16322            }
16323    
16324            /**
16325             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16326             *
16327             * @param displayDate the display date
16328             * @param status the status
16329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16330             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16331             * @throws SystemException if a system exception occurred
16332             */
16333            @Override
16334            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
16335                    OrderByComparator orderByComparator) throws SystemException {
16336                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
16337                                    orderByComparator);
16338    
16339                    if (!list.isEmpty()) {
16340                            return list.get(0);
16341                    }
16342    
16343                    return null;
16344            }
16345    
16346            /**
16347             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16348             *
16349             * @param displayDate the display date
16350             * @param status the status
16351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16352             * @return the last matching journal article
16353             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16354             * @throws SystemException if a system exception occurred
16355             */
16356            @Override
16357            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
16358                    OrderByComparator orderByComparator)
16359                    throws NoSuchArticleException, SystemException {
16360                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
16361                                    orderByComparator);
16362    
16363                    if (journalArticle != null) {
16364                            return journalArticle;
16365                    }
16366    
16367                    StringBundler msg = new StringBundler(6);
16368    
16369                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16370    
16371                    msg.append("displayDate=");
16372                    msg.append(displayDate);
16373    
16374                    msg.append(", status=");
16375                    msg.append(status);
16376    
16377                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16378    
16379                    throw new NoSuchArticleException(msg.toString());
16380            }
16381    
16382            /**
16383             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16384             *
16385             * @param displayDate the display date
16386             * @param status the status
16387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16388             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16389             * @throws SystemException if a system exception occurred
16390             */
16391            @Override
16392            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
16393                    OrderByComparator orderByComparator) throws SystemException {
16394                    int count = countByLtD_S(displayDate, status);
16395    
16396                    if (count == 0) {
16397                            return null;
16398                    }
16399    
16400                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
16401                                    count, orderByComparator);
16402    
16403                    if (!list.isEmpty()) {
16404                            return list.get(0);
16405                    }
16406    
16407                    return null;
16408            }
16409    
16410            /**
16411             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
16412             *
16413             * @param id the primary key of the current journal article
16414             * @param displayDate the display date
16415             * @param status the status
16416             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16417             * @return the previous, current, and next journal article
16418             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16419             * @throws SystemException if a system exception occurred
16420             */
16421            @Override
16422            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
16423                    int status, OrderByComparator orderByComparator)
16424                    throws NoSuchArticleException, SystemException {
16425                    JournalArticle journalArticle = findByPrimaryKey(id);
16426    
16427                    Session session = null;
16428    
16429                    try {
16430                            session = openSession();
16431    
16432                            JournalArticle[] array = new JournalArticleImpl[3];
16433    
16434                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
16435                                            displayDate, status, orderByComparator, true);
16436    
16437                            array[1] = journalArticle;
16438    
16439                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
16440                                            displayDate, status, orderByComparator, false);
16441    
16442                            return array;
16443                    }
16444                    catch (Exception e) {
16445                            throw processException(e);
16446                    }
16447                    finally {
16448                            closeSession(session);
16449                    }
16450            }
16451    
16452            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
16453                    JournalArticle journalArticle, Date displayDate, int status,
16454                    OrderByComparator orderByComparator, boolean previous) {
16455                    StringBundler query = null;
16456    
16457                    if (orderByComparator != null) {
16458                            query = new StringBundler(6 +
16459                                            (orderByComparator.getOrderByFields().length * 6));
16460                    }
16461                    else {
16462                            query = new StringBundler(3);
16463                    }
16464    
16465                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16466    
16467                    boolean bindDisplayDate = false;
16468    
16469                    if (displayDate == null) {
16470                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
16471                    }
16472                    else {
16473                            bindDisplayDate = true;
16474    
16475                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
16476                    }
16477    
16478                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
16479    
16480                    if (orderByComparator != null) {
16481                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16482    
16483                            if (orderByConditionFields.length > 0) {
16484                                    query.append(WHERE_AND);
16485                            }
16486    
16487                            for (int i = 0; i < orderByConditionFields.length; i++) {
16488                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16489                                    query.append(orderByConditionFields[i]);
16490    
16491                                    if ((i + 1) < orderByConditionFields.length) {
16492                                            if (orderByComparator.isAscending() ^ previous) {
16493                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16494                                            }
16495                                            else {
16496                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16497                                            }
16498                                    }
16499                                    else {
16500                                            if (orderByComparator.isAscending() ^ previous) {
16501                                                    query.append(WHERE_GREATER_THAN);
16502                                            }
16503                                            else {
16504                                                    query.append(WHERE_LESSER_THAN);
16505                                            }
16506                                    }
16507                            }
16508    
16509                            query.append(ORDER_BY_CLAUSE);
16510    
16511                            String[] orderByFields = orderByComparator.getOrderByFields();
16512    
16513                            for (int i = 0; i < orderByFields.length; i++) {
16514                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16515                                    query.append(orderByFields[i]);
16516    
16517                                    if ((i + 1) < orderByFields.length) {
16518                                            if (orderByComparator.isAscending() ^ previous) {
16519                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16520                                            }
16521                                            else {
16522                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16523                                            }
16524                                    }
16525                                    else {
16526                                            if (orderByComparator.isAscending() ^ previous) {
16527                                                    query.append(ORDER_BY_ASC);
16528                                            }
16529                                            else {
16530                                                    query.append(ORDER_BY_DESC);
16531                                            }
16532                                    }
16533                            }
16534                    }
16535                    else {
16536                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16537                    }
16538    
16539                    String sql = query.toString();
16540    
16541                    Query q = session.createQuery(sql);
16542    
16543                    q.setFirstResult(0);
16544                    q.setMaxResults(2);
16545    
16546                    QueryPos qPos = QueryPos.getInstance(q);
16547    
16548                    if (bindDisplayDate) {
16549                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16550                    }
16551    
16552                    qPos.add(status);
16553    
16554                    if (orderByComparator != null) {
16555                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16556    
16557                            for (Object value : values) {
16558                                    qPos.add(value);
16559                            }
16560                    }
16561    
16562                    List<JournalArticle> list = q.list();
16563    
16564                    if (list.size() == 2) {
16565                            return list.get(1);
16566                    }
16567                    else {
16568                            return null;
16569                    }
16570            }
16571    
16572            /**
16573             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
16574             *
16575             * @param displayDate the display date
16576             * @param status the status
16577             * @throws SystemException if a system exception occurred
16578             */
16579            @Override
16580            public void removeByLtD_S(Date displayDate, int status)
16581                    throws SystemException {
16582                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
16583                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16584                            remove(journalArticle);
16585                    }
16586            }
16587    
16588            /**
16589             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
16590             *
16591             * @param displayDate the display date
16592             * @param status the status
16593             * @return the number of matching journal articles
16594             * @throws SystemException if a system exception occurred
16595             */
16596            @Override
16597            public int countByLtD_S(Date displayDate, int status)
16598                    throws SystemException {
16599                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
16600    
16601                    Object[] finderArgs = new Object[] { displayDate, status };
16602    
16603                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16604                                    this);
16605    
16606                    if (count == null) {
16607                            StringBundler query = new StringBundler(3);
16608    
16609                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16610    
16611                            boolean bindDisplayDate = false;
16612    
16613                            if (displayDate == null) {
16614                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
16615                            }
16616                            else {
16617                                    bindDisplayDate = true;
16618    
16619                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
16620                            }
16621    
16622                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
16623    
16624                            String sql = query.toString();
16625    
16626                            Session session = null;
16627    
16628                            try {
16629                                    session = openSession();
16630    
16631                                    Query q = session.createQuery(sql);
16632    
16633                                    QueryPos qPos = QueryPos.getInstance(q);
16634    
16635                                    if (bindDisplayDate) {
16636                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16637                                    }
16638    
16639                                    qPos.add(status);
16640    
16641                                    count = (Long)q.uniqueResult();
16642    
16643                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16644                            }
16645                            catch (Exception e) {
16646                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16647    
16648                                    throw processException(e);
16649                            }
16650                            finally {
16651                                    closeSession(session);
16652                            }
16653                    }
16654    
16655                    return count.intValue();
16656            }
16657    
16658            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
16659            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
16660            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
16661            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16662                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16663                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16664                            "findByR_I_S",
16665                            new String[] {
16666                                    Long.class.getName(), Boolean.class.getName(),
16667                                    Integer.class.getName(),
16668                                    
16669                            Integer.class.getName(), Integer.class.getName(),
16670                                    OrderByComparator.class.getName()
16671                            });
16672            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16673                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16674                            JournalArticleImpl.class,
16675                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
16676                            new String[] {
16677                                    Long.class.getName(), Boolean.class.getName(),
16678                                    Integer.class.getName()
16679                            },
16680                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
16681                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
16682                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
16683                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16684                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16685            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16686                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16687                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
16688                            new String[] {
16689                                    Long.class.getName(), Boolean.class.getName(),
16690                                    Integer.class.getName()
16691                            });
16692            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16693                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16694                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
16695                            new String[] {
16696                                    Long.class.getName(), Boolean.class.getName(),
16697                                    Integer.class.getName()
16698                            });
16699    
16700            /**
16701             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16702             *
16703             * @param resourcePrimKey the resource prim key
16704             * @param indexable the indexable
16705             * @param status the status
16706             * @return the matching journal articles
16707             * @throws SystemException if a system exception occurred
16708             */
16709            @Override
16710            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16711                    boolean indexable, int status) throws SystemException {
16712                    return findByR_I_S(resourcePrimKey, indexable, status,
16713                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16714            }
16715    
16716            /**
16717             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16718             *
16719             * <p>
16720             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16721             * </p>
16722             *
16723             * @param resourcePrimKey the resource prim key
16724             * @param indexable the indexable
16725             * @param status the status
16726             * @param start the lower bound of the range of journal articles
16727             * @param end the upper bound of the range of journal articles (not inclusive)
16728             * @return the range of matching journal articles
16729             * @throws SystemException if a system exception occurred
16730             */
16731            @Override
16732            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16733                    boolean indexable, int status, int start, int end)
16734                    throws SystemException {
16735                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
16736            }
16737    
16738            /**
16739             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16740             *
16741             * <p>
16742             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16743             * </p>
16744             *
16745             * @param resourcePrimKey the resource prim key
16746             * @param indexable the indexable
16747             * @param status the status
16748             * @param start the lower bound of the range of journal articles
16749             * @param end the upper bound of the range of journal articles (not inclusive)
16750             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16751             * @return the ordered range of matching journal articles
16752             * @throws SystemException if a system exception occurred
16753             */
16754            @Override
16755            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16756                    boolean indexable, int status, int start, int end,
16757                    OrderByComparator orderByComparator) throws SystemException {
16758                    boolean pagination = true;
16759                    FinderPath finderPath = null;
16760                    Object[] finderArgs = null;
16761    
16762                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16763                                    (orderByComparator == null)) {
16764                            pagination = false;
16765                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
16766                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
16767                    }
16768                    else {
16769                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
16770                            finderArgs = new Object[] {
16771                                            resourcePrimKey, indexable, status,
16772                                            
16773                                            start, end, orderByComparator
16774                                    };
16775                    }
16776    
16777                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16778                                    finderArgs, this);
16779    
16780                    if ((list != null) && !list.isEmpty()) {
16781                            for (JournalArticle journalArticle : list) {
16782                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
16783                                                    (indexable != journalArticle.getIndexable()) ||
16784                                                    (status != journalArticle.getStatus())) {
16785                                            list = null;
16786    
16787                                            break;
16788                                    }
16789                            }
16790                    }
16791    
16792                    if (list == null) {
16793                            StringBundler query = null;
16794    
16795                            if (orderByComparator != null) {
16796                                    query = new StringBundler(5 +
16797                                                    (orderByComparator.getOrderByFields().length * 3));
16798                            }
16799                            else {
16800                                    query = new StringBundler(5);
16801                            }
16802    
16803                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16804    
16805                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
16806    
16807                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
16808    
16809                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
16810    
16811                            if (orderByComparator != null) {
16812                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16813                                            orderByComparator);
16814                            }
16815                            else
16816                             if (pagination) {
16817                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16818                            }
16819    
16820                            String sql = query.toString();
16821    
16822                            Session session = null;
16823    
16824                            try {
16825                                    session = openSession();
16826    
16827                                    Query q = session.createQuery(sql);
16828    
16829                                    QueryPos qPos = QueryPos.getInstance(q);
16830    
16831                                    qPos.add(resourcePrimKey);
16832    
16833                                    qPos.add(indexable);
16834    
16835                                    qPos.add(status);
16836    
16837                                    if (!pagination) {
16838                                            list = (List<JournalArticle>)QueryUtil.list(q,
16839                                                            getDialect(), start, end, false);
16840    
16841                                            Collections.sort(list);
16842    
16843                                            list = new UnmodifiableList<JournalArticle>(list);
16844                                    }
16845                                    else {
16846                                            list = (List<JournalArticle>)QueryUtil.list(q,
16847                                                            getDialect(), start, end);
16848                                    }
16849    
16850                                    cacheResult(list);
16851    
16852                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16853                            }
16854                            catch (Exception e) {
16855                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16856    
16857                                    throw processException(e);
16858                            }
16859                            finally {
16860                                    closeSession(session);
16861                            }
16862                    }
16863    
16864                    return list;
16865            }
16866    
16867            /**
16868             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16869             *
16870             * @param resourcePrimKey the resource prim key
16871             * @param indexable the indexable
16872             * @param status the status
16873             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16874             * @return the first matching journal article
16875             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16876             * @throws SystemException if a system exception occurred
16877             */
16878            @Override
16879            public JournalArticle findByR_I_S_First(long resourcePrimKey,
16880                    boolean indexable, int status, OrderByComparator orderByComparator)
16881                    throws NoSuchArticleException, SystemException {
16882                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
16883                                    indexable, status, orderByComparator);
16884    
16885                    if (journalArticle != null) {
16886                            return journalArticle;
16887                    }
16888    
16889                    StringBundler msg = new StringBundler(8);
16890    
16891                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16892    
16893                    msg.append("resourcePrimKey=");
16894                    msg.append(resourcePrimKey);
16895    
16896                    msg.append(", indexable=");
16897                    msg.append(indexable);
16898    
16899                    msg.append(", status=");
16900                    msg.append(status);
16901    
16902                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16903    
16904                    throw new NoSuchArticleException(msg.toString());
16905            }
16906    
16907            /**
16908             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16909             *
16910             * @param resourcePrimKey the resource prim key
16911             * @param indexable the indexable
16912             * @param status the status
16913             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16914             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16915             * @throws SystemException if a system exception occurred
16916             */
16917            @Override
16918            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
16919                    boolean indexable, int status, OrderByComparator orderByComparator)
16920                    throws SystemException {
16921                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
16922                                    status, 0, 1, orderByComparator);
16923    
16924                    if (!list.isEmpty()) {
16925                            return list.get(0);
16926                    }
16927    
16928                    return null;
16929            }
16930    
16931            /**
16932             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16933             *
16934             * @param resourcePrimKey the resource prim key
16935             * @param indexable the indexable
16936             * @param status the status
16937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16938             * @return the last matching journal article
16939             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16940             * @throws SystemException if a system exception occurred
16941             */
16942            @Override
16943            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
16944                    boolean indexable, int status, OrderByComparator orderByComparator)
16945                    throws NoSuchArticleException, SystemException {
16946                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
16947                                    indexable, status, orderByComparator);
16948    
16949                    if (journalArticle != null) {
16950                            return journalArticle;
16951                    }
16952    
16953                    StringBundler msg = new StringBundler(8);
16954    
16955                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16956    
16957                    msg.append("resourcePrimKey=");
16958                    msg.append(resourcePrimKey);
16959    
16960                    msg.append(", indexable=");
16961                    msg.append(indexable);
16962    
16963                    msg.append(", status=");
16964                    msg.append(status);
16965    
16966                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16967    
16968                    throw new NoSuchArticleException(msg.toString());
16969            }
16970    
16971            /**
16972             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16973             *
16974             * @param resourcePrimKey the resource prim key
16975             * @param indexable the indexable
16976             * @param status the status
16977             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16978             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16979             * @throws SystemException if a system exception occurred
16980             */
16981            @Override
16982            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
16983                    boolean indexable, int status, OrderByComparator orderByComparator)
16984                    throws SystemException {
16985                    int count = countByR_I_S(resourcePrimKey, indexable, status);
16986    
16987                    if (count == 0) {
16988                            return null;
16989                    }
16990    
16991                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
16992                                    status, count - 1, count, orderByComparator);
16993    
16994                    if (!list.isEmpty()) {
16995                            return list.get(0);
16996                    }
16997    
16998                    return null;
16999            }
17000    
17001            /**
17002             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17003             *
17004             * @param id the primary key of the current journal article
17005             * @param resourcePrimKey the resource prim key
17006             * @param indexable the indexable
17007             * @param status the status
17008             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17009             * @return the previous, current, and next journal article
17010             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17011             * @throws SystemException if a system exception occurred
17012             */
17013            @Override
17014            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
17015                    long resourcePrimKey, boolean indexable, int status,
17016                    OrderByComparator orderByComparator)
17017                    throws NoSuchArticleException, SystemException {
17018                    JournalArticle journalArticle = findByPrimaryKey(id);
17019    
17020                    Session session = null;
17021    
17022                    try {
17023                            session = openSession();
17024    
17025                            JournalArticle[] array = new JournalArticleImpl[3];
17026    
17027                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
17028                                            resourcePrimKey, indexable, status, orderByComparator, true);
17029    
17030                            array[1] = journalArticle;
17031    
17032                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
17033                                            resourcePrimKey, indexable, status, orderByComparator, false);
17034    
17035                            return array;
17036                    }
17037                    catch (Exception e) {
17038                            throw processException(e);
17039                    }
17040                    finally {
17041                            closeSession(session);
17042                    }
17043            }
17044    
17045            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
17046                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
17047                    int status, OrderByComparator orderByComparator, boolean previous) {
17048                    StringBundler query = null;
17049    
17050                    if (orderByComparator != null) {
17051                            query = new StringBundler(6 +
17052                                            (orderByComparator.getOrderByFields().length * 6));
17053                    }
17054                    else {
17055                            query = new StringBundler(3);
17056                    }
17057    
17058                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17059    
17060                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17061    
17062                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17063    
17064                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17065    
17066                    if (orderByComparator != null) {
17067                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17068    
17069                            if (orderByConditionFields.length > 0) {
17070                                    query.append(WHERE_AND);
17071                            }
17072    
17073                            for (int i = 0; i < orderByConditionFields.length; i++) {
17074                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17075                                    query.append(orderByConditionFields[i]);
17076    
17077                                    if ((i + 1) < orderByConditionFields.length) {
17078                                            if (orderByComparator.isAscending() ^ previous) {
17079                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17080                                            }
17081                                            else {
17082                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17083                                            }
17084                                    }
17085                                    else {
17086                                            if (orderByComparator.isAscending() ^ previous) {
17087                                                    query.append(WHERE_GREATER_THAN);
17088                                            }
17089                                            else {
17090                                                    query.append(WHERE_LESSER_THAN);
17091                                            }
17092                                    }
17093                            }
17094    
17095                            query.append(ORDER_BY_CLAUSE);
17096    
17097                            String[] orderByFields = orderByComparator.getOrderByFields();
17098    
17099                            for (int i = 0; i < orderByFields.length; i++) {
17100                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17101                                    query.append(orderByFields[i]);
17102    
17103                                    if ((i + 1) < orderByFields.length) {
17104                                            if (orderByComparator.isAscending() ^ previous) {
17105                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17106                                            }
17107                                            else {
17108                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17109                                            }
17110                                    }
17111                                    else {
17112                                            if (orderByComparator.isAscending() ^ previous) {
17113                                                    query.append(ORDER_BY_ASC);
17114                                            }
17115                                            else {
17116                                                    query.append(ORDER_BY_DESC);
17117                                            }
17118                                    }
17119                            }
17120                    }
17121                    else {
17122                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17123                    }
17124    
17125                    String sql = query.toString();
17126    
17127                    Query q = session.createQuery(sql);
17128    
17129                    q.setFirstResult(0);
17130                    q.setMaxResults(2);
17131    
17132                    QueryPos qPos = QueryPos.getInstance(q);
17133    
17134                    qPos.add(resourcePrimKey);
17135    
17136                    qPos.add(indexable);
17137    
17138                    qPos.add(status);
17139    
17140                    if (orderByComparator != null) {
17141                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17142    
17143                            for (Object value : values) {
17144                                    qPos.add(value);
17145                            }
17146                    }
17147    
17148                    List<JournalArticle> list = q.list();
17149    
17150                    if (list.size() == 2) {
17151                            return list.get(1);
17152                    }
17153                    else {
17154                            return null;
17155                    }
17156            }
17157    
17158            /**
17159             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17160             *
17161             * <p>
17162             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17163             * </p>
17164             *
17165             * @param resourcePrimKey the resource prim key
17166             * @param indexable the indexable
17167             * @param statuses the statuses
17168             * @return the matching journal articles
17169             * @throws SystemException if a system exception occurred
17170             */
17171            @Override
17172            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17173                    boolean indexable, int[] statuses) throws SystemException {
17174                    return findByR_I_S(resourcePrimKey, indexable, statuses,
17175                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17176            }
17177    
17178            /**
17179             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17180             *
17181             * <p>
17182             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17183             * </p>
17184             *
17185             * @param resourcePrimKey the resource prim key
17186             * @param indexable the indexable
17187             * @param statuses the statuses
17188             * @param start the lower bound of the range of journal articles
17189             * @param end the upper bound of the range of journal articles (not inclusive)
17190             * @return the range of matching journal articles
17191             * @throws SystemException if a system exception occurred
17192             */
17193            @Override
17194            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17195                    boolean indexable, int[] statuses, int start, int end)
17196                    throws SystemException {
17197                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
17198                            null);
17199            }
17200    
17201            /**
17202             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17203             *
17204             * <p>
17205             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17206             * </p>
17207             *
17208             * @param resourcePrimKey the resource prim key
17209             * @param indexable the indexable
17210             * @param statuses the statuses
17211             * @param start the lower bound of the range of journal articles
17212             * @param end the upper bound of the range of journal articles (not inclusive)
17213             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17214             * @return the ordered range of matching journal articles
17215             * @throws SystemException if a system exception occurred
17216             */
17217            @Override
17218            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17219                    boolean indexable, int[] statuses, int start, int end,
17220                    OrderByComparator orderByComparator) throws SystemException {
17221                    if ((statuses != null) && (statuses.length == 1)) {
17222                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
17223                                    end, orderByComparator);
17224                    }
17225    
17226                    boolean pagination = true;
17227                    Object[] finderArgs = null;
17228    
17229                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17230                                    (orderByComparator == null)) {
17231                            pagination = false;
17232                            finderArgs = new Object[] {
17233                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
17234                                    };
17235                    }
17236                    else {
17237                            finderArgs = new Object[] {
17238                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
17239                                            
17240                                            start, end, orderByComparator
17241                                    };
17242                    }
17243    
17244                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
17245                                    finderArgs, this);
17246    
17247                    if ((list != null) && !list.isEmpty()) {
17248                            for (JournalArticle journalArticle : list) {
17249                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
17250                                                    (indexable != journalArticle.getIndexable()) ||
17251                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
17252                                            list = null;
17253    
17254                                            break;
17255                                    }
17256                            }
17257                    }
17258    
17259                    if (list == null) {
17260                            StringBundler query = new StringBundler();
17261    
17262                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17263    
17264                            boolean conjunctionable = false;
17265    
17266                            if (conjunctionable) {
17267                                    query.append(WHERE_AND);
17268                            }
17269    
17270                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
17271    
17272                            conjunctionable = true;
17273    
17274                            if (conjunctionable) {
17275                                    query.append(WHERE_AND);
17276                            }
17277    
17278                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
17279    
17280                            conjunctionable = true;
17281    
17282                            if ((statuses == null) || (statuses.length > 0)) {
17283                                    if (conjunctionable) {
17284                                            query.append(WHERE_AND);
17285                                    }
17286    
17287                                    query.append(StringPool.OPEN_PARENTHESIS);
17288    
17289                                    for (int i = 0; i < statuses.length; i++) {
17290                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
17291    
17292                                            if ((i + 1) < statuses.length) {
17293                                                    query.append(WHERE_OR);
17294                                            }
17295                                    }
17296    
17297                                    query.append(StringPool.CLOSE_PARENTHESIS);
17298    
17299                                    conjunctionable = true;
17300                            }
17301    
17302                            if (orderByComparator != null) {
17303                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17304                                            orderByComparator);
17305                            }
17306                            else
17307                             if (pagination) {
17308                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17309                            }
17310    
17311                            String sql = query.toString();
17312    
17313                            Session session = null;
17314    
17315                            try {
17316                                    session = openSession();
17317    
17318                                    Query q = session.createQuery(sql);
17319    
17320                                    QueryPos qPos = QueryPos.getInstance(q);
17321    
17322                                    qPos.add(resourcePrimKey);
17323    
17324                                    qPos.add(indexable);
17325    
17326                                    if (statuses != null) {
17327                                            qPos.add(statuses);
17328                                    }
17329    
17330                                    if (!pagination) {
17331                                            list = (List<JournalArticle>)QueryUtil.list(q,
17332                                                            getDialect(), start, end, false);
17333    
17334                                            Collections.sort(list);
17335    
17336                                            list = new UnmodifiableList<JournalArticle>(list);
17337                                    }
17338                                    else {
17339                                            list = (List<JournalArticle>)QueryUtil.list(q,
17340                                                            getDialect(), start, end);
17341                                    }
17342    
17343                                    cacheResult(list);
17344    
17345                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
17346                                            finderArgs, list);
17347                            }
17348                            catch (Exception e) {
17349                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
17350                                            finderArgs);
17351    
17352                                    throw processException(e);
17353                            }
17354                            finally {
17355                                    closeSession(session);
17356                            }
17357                    }
17358    
17359                    return list;
17360            }
17361    
17362            /**
17363             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
17364             *
17365             * @param resourcePrimKey the resource prim key
17366             * @param indexable the indexable
17367             * @param status the status
17368             * @throws SystemException if a system exception occurred
17369             */
17370            @Override
17371            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
17372                    int status) throws SystemException {
17373                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
17374                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17375                            remove(journalArticle);
17376                    }
17377            }
17378    
17379            /**
17380             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17381             *
17382             * @param resourcePrimKey the resource prim key
17383             * @param indexable the indexable
17384             * @param status the status
17385             * @return the number of matching journal articles
17386             * @throws SystemException if a system exception occurred
17387             */
17388            @Override
17389            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status)
17390                    throws SystemException {
17391                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
17392    
17393                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
17394    
17395                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17396                                    this);
17397    
17398                    if (count == null) {
17399                            StringBundler query = new StringBundler(4);
17400    
17401                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17402    
17403                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17404    
17405                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17406    
17407                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17408    
17409                            String sql = query.toString();
17410    
17411                            Session session = null;
17412    
17413                            try {
17414                                    session = openSession();
17415    
17416                                    Query q = session.createQuery(sql);
17417    
17418                                    QueryPos qPos = QueryPos.getInstance(q);
17419    
17420                                    qPos.add(resourcePrimKey);
17421    
17422                                    qPos.add(indexable);
17423    
17424                                    qPos.add(status);
17425    
17426                                    count = (Long)q.uniqueResult();
17427    
17428                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17429                            }
17430                            catch (Exception e) {
17431                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17432    
17433                                    throw processException(e);
17434                            }
17435                            finally {
17436                                    closeSession(session);
17437                            }
17438                    }
17439    
17440                    return count.intValue();
17441            }
17442    
17443            /**
17444             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
17445             *
17446             * @param resourcePrimKey the resource prim key
17447             * @param indexable the indexable
17448             * @param statuses the statuses
17449             * @return the number of matching journal articles
17450             * @throws SystemException if a system exception occurred
17451             */
17452            @Override
17453            public int countByR_I_S(long resourcePrimKey, boolean indexable,
17454                    int[] statuses) throws SystemException {
17455                    Object[] finderArgs = new Object[] {
17456                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
17457                            };
17458    
17459                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
17460                                    finderArgs, this);
17461    
17462                    if (count == null) {
17463                            StringBundler query = new StringBundler();
17464    
17465                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17466    
17467                            boolean conjunctionable = false;
17468    
17469                            if (conjunctionable) {
17470                                    query.append(WHERE_AND);
17471                            }
17472    
17473                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
17474    
17475                            conjunctionable = true;
17476    
17477                            if (conjunctionable) {
17478                                    query.append(WHERE_AND);
17479                            }
17480    
17481                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
17482    
17483                            conjunctionable = true;
17484    
17485                            if ((statuses == null) || (statuses.length > 0)) {
17486                                    if (conjunctionable) {
17487                                            query.append(WHERE_AND);
17488                                    }
17489    
17490                                    query.append(StringPool.OPEN_PARENTHESIS);
17491    
17492                                    for (int i = 0; i < statuses.length; i++) {
17493                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
17494    
17495                                            if ((i + 1) < statuses.length) {
17496                                                    query.append(WHERE_OR);
17497                                            }
17498                                    }
17499    
17500                                    query.append(StringPool.CLOSE_PARENTHESIS);
17501    
17502                                    conjunctionable = true;
17503                            }
17504    
17505                            String sql = query.toString();
17506    
17507                            Session session = null;
17508    
17509                            try {
17510                                    session = openSession();
17511    
17512                                    Query q = session.createQuery(sql);
17513    
17514                                    QueryPos qPos = QueryPos.getInstance(q);
17515    
17516                                    qPos.add(resourcePrimKey);
17517    
17518                                    qPos.add(indexable);
17519    
17520                                    if (statuses != null) {
17521                                            qPos.add(statuses);
17522                                    }
17523    
17524                                    count = (Long)q.uniqueResult();
17525    
17526                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
17527                                            finderArgs, count);
17528                            }
17529                            catch (Exception e) {
17530                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
17531                                            finderArgs);
17532    
17533                                    throw processException(e);
17534                            }
17535                            finally {
17536                                    closeSession(session);
17537                            }
17538                    }
17539    
17540                    return count.intValue();
17541            }
17542    
17543            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
17544            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5 = "(" +
17545                    removeConjunction(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2) + ")";
17546            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
17547            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_5 = "(" +
17548                    removeConjunction(_FINDER_COLUMN_R_I_S_INDEXABLE_2) + ")";
17549            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
17550            private static final String _FINDER_COLUMN_R_I_S_STATUS_5 = "(" +
17551                    removeConjunction(_FINDER_COLUMN_R_I_S_STATUS_2) + ")";
17552            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17553                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17554                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17555                            "findByG_F_ST",
17556                            new String[] {
17557                                    Long.class.getName(), Long.class.getName(),
17558                                    Integer.class.getName(),
17559                                    
17560                            Integer.class.getName(), Integer.class.getName(),
17561                                    OrderByComparator.class.getName()
17562                            });
17563            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
17564                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17565                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17566                            JournalArticleImpl.class,
17567                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
17568                            new String[] {
17569                                    Long.class.getName(), Long.class.getName(),
17570                                    Integer.class.getName()
17571                            },
17572                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
17573                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
17574                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
17575                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17576                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17577            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17578                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17579                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
17580                            new String[] {
17581                                    Long.class.getName(), Long.class.getName(),
17582                                    Integer.class.getName()
17583                            });
17584            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17585                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17586                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
17587                            new String[] {
17588                                    Long.class.getName(), Long.class.getName(),
17589                                    Integer.class.getName()
17590                            });
17591    
17592            /**
17593             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
17594             *
17595             * @param groupId the group ID
17596             * @param folderId the folder ID
17597             * @param status the status
17598             * @return the matching journal articles
17599             * @throws SystemException if a system exception occurred
17600             */
17601            @Override
17602            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
17603                    int status) throws SystemException {
17604                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
17605                            QueryUtil.ALL_POS, null);
17606            }
17607    
17608            /**
17609             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
17610             *
17611             * <p>
17612             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17613             * </p>
17614             *
17615             * @param groupId the group ID
17616             * @param folderId the folder ID
17617             * @param status the status
17618             * @param start the lower bound of the range of journal articles
17619             * @param end the upper bound of the range of journal articles (not inclusive)
17620             * @return the range of matching journal articles
17621             * @throws SystemException if a system exception occurred
17622             */
17623            @Override
17624            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
17625                    int status, int start, int end) throws SystemException {
17626                    return findByG_F_ST(groupId, folderId, status, start, end, null);
17627            }
17628    
17629            /**
17630             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
17631             *
17632             * <p>
17633             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17634             * </p>
17635             *
17636             * @param groupId the group ID
17637             * @param folderId the folder ID
17638             * @param status the status
17639             * @param start the lower bound of the range of journal articles
17640             * @param end the upper bound of the range of journal articles (not inclusive)
17641             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17642             * @return the ordered range of matching journal articles
17643             * @throws SystemException if a system exception occurred
17644             */
17645            @Override
17646            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
17647                    int status, int start, int end, OrderByComparator orderByComparator)
17648                    throws SystemException {
17649                    boolean pagination = true;
17650                    FinderPath finderPath = null;
17651                    Object[] finderArgs = null;
17652    
17653                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17654                                    (orderByComparator == null)) {
17655                            pagination = false;
17656                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
17657                            finderArgs = new Object[] { groupId, folderId, status };
17658                    }
17659                    else {
17660                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
17661                            finderArgs = new Object[] {
17662                                            groupId, folderId, status,
17663                                            
17664                                            start, end, orderByComparator
17665                                    };
17666                    }
17667    
17668                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17669                                    finderArgs, this);
17670    
17671                    if ((list != null) && !list.isEmpty()) {
17672                            for (JournalArticle journalArticle : list) {
17673                                    if ((groupId != journalArticle.getGroupId()) ||
17674                                                    (folderId != journalArticle.getFolderId()) ||
17675                                                    (status != journalArticle.getStatus())) {
17676                                            list = null;
17677    
17678                                            break;
17679                                    }
17680                            }
17681                    }
17682    
17683                    if (list == null) {
17684                            StringBundler query = null;
17685    
17686                            if (orderByComparator != null) {
17687                                    query = new StringBundler(5 +
17688                                                    (orderByComparator.getOrderByFields().length * 3));
17689                            }
17690                            else {
17691                                    query = new StringBundler(5);
17692                            }
17693    
17694                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17695    
17696                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
17697    
17698                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
17699    
17700                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
17701    
17702                            if (orderByComparator != null) {
17703                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17704                                            orderByComparator);
17705                            }
17706                            else
17707                             if (pagination) {
17708                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17709                            }
17710    
17711                            String sql = query.toString();
17712    
17713                            Session session = null;
17714    
17715                            try {
17716                                    session = openSession();
17717    
17718                                    Query q = session.createQuery(sql);
17719    
17720                                    QueryPos qPos = QueryPos.getInstance(q);
17721    
17722                                    qPos.add(groupId);
17723    
17724                                    qPos.add(folderId);
17725    
17726                                    qPos.add(status);
17727    
17728                                    if (!pagination) {
17729                                            list = (List<JournalArticle>)QueryUtil.list(q,
17730                                                            getDialect(), start, end, false);
17731    
17732                                            Collections.sort(list);
17733    
17734                                            list = new UnmodifiableList<JournalArticle>(list);
17735                                    }
17736                                    else {
17737                                            list = (List<JournalArticle>)QueryUtil.list(q,
17738                                                            getDialect(), start, end);
17739                                    }
17740    
17741                                    cacheResult(list);
17742    
17743                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17744                            }
17745                            catch (Exception e) {
17746                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17747    
17748                                    throw processException(e);
17749                            }
17750                            finally {
17751                                    closeSession(session);
17752                            }
17753                    }
17754    
17755                    return list;
17756            }
17757    
17758            /**
17759             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17760             *
17761             * @param groupId the group ID
17762             * @param folderId the folder ID
17763             * @param status the status
17764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17765             * @return the first matching journal article
17766             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17767             * @throws SystemException if a system exception occurred
17768             */
17769            @Override
17770            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
17771                    int status, OrderByComparator orderByComparator)
17772                    throws NoSuchArticleException, SystemException {
17773                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
17774                                    status, orderByComparator);
17775    
17776                    if (journalArticle != null) {
17777                            return journalArticle;
17778                    }
17779    
17780                    StringBundler msg = new StringBundler(8);
17781    
17782                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17783    
17784                    msg.append("groupId=");
17785                    msg.append(groupId);
17786    
17787                    msg.append(", folderId=");
17788                    msg.append(folderId);
17789    
17790                    msg.append(", status=");
17791                    msg.append(status);
17792    
17793                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17794    
17795                    throw new NoSuchArticleException(msg.toString());
17796            }
17797    
17798            /**
17799             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17800             *
17801             * @param groupId the group ID
17802             * @param folderId the folder ID
17803             * @param status the status
17804             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17805             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17806             * @throws SystemException if a system exception occurred
17807             */
17808            @Override
17809            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
17810                    int status, OrderByComparator orderByComparator)
17811                    throws SystemException {
17812                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
17813                                    1, orderByComparator);
17814    
17815                    if (!list.isEmpty()) {
17816                            return list.get(0);
17817                    }
17818    
17819                    return null;
17820            }
17821    
17822            /**
17823             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17824             *
17825             * @param groupId the group ID
17826             * @param folderId the folder ID
17827             * @param status the status
17828             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17829             * @return the last matching journal article
17830             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17831             * @throws SystemException if a system exception occurred
17832             */
17833            @Override
17834            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
17835                    int status, OrderByComparator orderByComparator)
17836                    throws NoSuchArticleException, SystemException {
17837                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
17838                                    status, orderByComparator);
17839    
17840                    if (journalArticle != null) {
17841                            return journalArticle;
17842                    }
17843    
17844                    StringBundler msg = new StringBundler(8);
17845    
17846                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17847    
17848                    msg.append("groupId=");
17849                    msg.append(groupId);
17850    
17851                    msg.append(", folderId=");
17852                    msg.append(folderId);
17853    
17854                    msg.append(", status=");
17855                    msg.append(status);
17856    
17857                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17858    
17859                    throw new NoSuchArticleException(msg.toString());
17860            }
17861    
17862            /**
17863             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17864             *
17865             * @param groupId the group ID
17866             * @param folderId the folder ID
17867             * @param status the status
17868             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17869             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17870             * @throws SystemException if a system exception occurred
17871             */
17872            @Override
17873            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
17874                    int status, OrderByComparator orderByComparator)
17875                    throws SystemException {
17876                    int count = countByG_F_ST(groupId, folderId, status);
17877    
17878                    if (count == 0) {
17879                            return null;
17880                    }
17881    
17882                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
17883                                    count - 1, count, orderByComparator);
17884    
17885                    if (!list.isEmpty()) {
17886                            return list.get(0);
17887                    }
17888    
17889                    return null;
17890            }
17891    
17892            /**
17893             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17894             *
17895             * @param id the primary key of the current journal article
17896             * @param groupId the group ID
17897             * @param folderId the folder ID
17898             * @param status the status
17899             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17900             * @return the previous, current, and next journal article
17901             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17902             * @throws SystemException if a system exception occurred
17903             */
17904            @Override
17905            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
17906                    long folderId, int status, OrderByComparator orderByComparator)
17907                    throws NoSuchArticleException, SystemException {
17908                    JournalArticle journalArticle = findByPrimaryKey(id);
17909    
17910                    Session session = null;
17911    
17912                    try {
17913                            session = openSession();
17914    
17915                            JournalArticle[] array = new JournalArticleImpl[3];
17916    
17917                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
17918                                            groupId, folderId, status, orderByComparator, true);
17919    
17920                            array[1] = journalArticle;
17921    
17922                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
17923                                            groupId, folderId, status, orderByComparator, false);
17924    
17925                            return array;
17926                    }
17927                    catch (Exception e) {
17928                            throw processException(e);
17929                    }
17930                    finally {
17931                            closeSession(session);
17932                    }
17933            }
17934    
17935            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
17936                    JournalArticle journalArticle, long groupId, long folderId, int status,
17937                    OrderByComparator orderByComparator, boolean previous) {
17938                    StringBundler query = null;
17939    
17940                    if (orderByComparator != null) {
17941                            query = new StringBundler(6 +
17942                                            (orderByComparator.getOrderByFields().length * 6));
17943                    }
17944                    else {
17945                            query = new StringBundler(3);
17946                    }
17947    
17948                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17949    
17950                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
17951    
17952                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
17953    
17954                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
17955    
17956                    if (orderByComparator != null) {
17957                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17958    
17959                            if (orderByConditionFields.length > 0) {
17960                                    query.append(WHERE_AND);
17961                            }
17962    
17963                            for (int i = 0; i < orderByConditionFields.length; i++) {
17964                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17965                                    query.append(orderByConditionFields[i]);
17966    
17967                                    if ((i + 1) < orderByConditionFields.length) {
17968                                            if (orderByComparator.isAscending() ^ previous) {
17969                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17970                                            }
17971                                            else {
17972                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17973                                            }
17974                                    }
17975                                    else {
17976                                            if (orderByComparator.isAscending() ^ previous) {
17977                                                    query.append(WHERE_GREATER_THAN);
17978                                            }
17979                                            else {
17980                                                    query.append(WHERE_LESSER_THAN);
17981                                            }
17982                                    }
17983                            }
17984    
17985                            query.append(ORDER_BY_CLAUSE);
17986    
17987                            String[] orderByFields = orderByComparator.getOrderByFields();
17988    
17989                            for (int i = 0; i < orderByFields.length; i++) {
17990                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17991                                    query.append(orderByFields[i]);
17992    
17993                                    if ((i + 1) < orderByFields.length) {
17994                                            if (orderByComparator.isAscending() ^ previous) {
17995                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17996                                            }
17997                                            else {
17998                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17999                                            }
18000                                    }
18001                                    else {
18002                                            if (orderByComparator.isAscending() ^ previous) {
18003                                                    query.append(ORDER_BY_ASC);
18004                                            }
18005                                            else {
18006                                                    query.append(ORDER_BY_DESC);
18007                                            }
18008                                    }
18009                            }
18010                    }
18011                    else {
18012                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18013                    }
18014    
18015                    String sql = query.toString();
18016    
18017                    Query q = session.createQuery(sql);
18018    
18019                    q.setFirstResult(0);
18020                    q.setMaxResults(2);
18021    
18022                    QueryPos qPos = QueryPos.getInstance(q);
18023    
18024                    qPos.add(groupId);
18025    
18026                    qPos.add(folderId);
18027    
18028                    qPos.add(status);
18029    
18030                    if (orderByComparator != null) {
18031                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18032    
18033                            for (Object value : values) {
18034                                    qPos.add(value);
18035                            }
18036                    }
18037    
18038                    List<JournalArticle> list = q.list();
18039    
18040                    if (list.size() == 2) {
18041                            return list.get(1);
18042                    }
18043                    else {
18044                            return null;
18045                    }
18046            }
18047    
18048            /**
18049             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
18050             *
18051             * @param groupId the group ID
18052             * @param folderId the folder ID
18053             * @param status the status
18054             * @return the matching journal articles that the user has permission to view
18055             * @throws SystemException if a system exception occurred
18056             */
18057            @Override
18058            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
18059                    int status) throws SystemException {
18060                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
18061                            QueryUtil.ALL_POS, null);
18062            }
18063    
18064            /**
18065             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
18066             *
18067             * <p>
18068             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18069             * </p>
18070             *
18071             * @param groupId the group ID
18072             * @param folderId the folder ID
18073             * @param status the status
18074             * @param start the lower bound of the range of journal articles
18075             * @param end the upper bound of the range of journal articles (not inclusive)
18076             * @return the range of matching journal articles that the user has permission to view
18077             * @throws SystemException if a system exception occurred
18078             */
18079            @Override
18080            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
18081                    int status, int start, int end) throws SystemException {
18082                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
18083            }
18084    
18085            /**
18086             * 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;.
18087             *
18088             * <p>
18089             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18090             * </p>
18091             *
18092             * @param groupId the group ID
18093             * @param folderId the folder ID
18094             * @param status the status
18095             * @param start the lower bound of the range of journal articles
18096             * @param end the upper bound of the range of journal articles (not inclusive)
18097             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18098             * @return the ordered range of matching journal articles that the user has permission to view
18099             * @throws SystemException if a system exception occurred
18100             */
18101            @Override
18102            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
18103                    int status, int start, int end, OrderByComparator orderByComparator)
18104                    throws SystemException {
18105                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18106                            return findByG_F_ST(groupId, folderId, status, start, end,
18107                                    orderByComparator);
18108                    }
18109    
18110                    StringBundler query = null;
18111    
18112                    if (orderByComparator != null) {
18113                            query = new StringBundler(5 +
18114                                            (orderByComparator.getOrderByFields().length * 3));
18115                    }
18116                    else {
18117                            query = new StringBundler(5);
18118                    }
18119    
18120                    if (getDB().isSupportsInlineDistinct()) {
18121                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18122                    }
18123                    else {
18124                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18125                    }
18126    
18127                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
18128    
18129                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
18130    
18131                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
18132    
18133                    if (!getDB().isSupportsInlineDistinct()) {
18134                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18135                    }
18136    
18137                    if (orderByComparator != null) {
18138                            if (getDB().isSupportsInlineDistinct()) {
18139                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18140                                            orderByComparator, true);
18141                            }
18142                            else {
18143                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18144                                            orderByComparator, true);
18145                            }
18146                    }
18147                    else {
18148                            if (getDB().isSupportsInlineDistinct()) {
18149                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18150                            }
18151                            else {
18152                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18153                            }
18154                    }
18155    
18156                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18157                                    JournalArticle.class.getName(),
18158                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18159    
18160                    Session session = null;
18161    
18162                    try {
18163                            session = openSession();
18164    
18165                            SQLQuery q = session.createSQLQuery(sql);
18166    
18167                            if (getDB().isSupportsInlineDistinct()) {
18168                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18169                            }
18170                            else {
18171                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18172                            }
18173    
18174                            QueryPos qPos = QueryPos.getInstance(q);
18175    
18176                            qPos.add(groupId);
18177    
18178                            qPos.add(folderId);
18179    
18180                            qPos.add(status);
18181    
18182                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18183                                    end);
18184                    }
18185                    catch (Exception e) {
18186                            throw processException(e);
18187                    }
18188                    finally {
18189                            closeSession(session);
18190                    }
18191            }
18192    
18193            /**
18194             * 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;.
18195             *
18196             * @param id the primary key of the current journal article
18197             * @param groupId the group ID
18198             * @param folderId the folder ID
18199             * @param status the status
18200             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18201             * @return the previous, current, and next journal article
18202             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18203             * @throws SystemException if a system exception occurred
18204             */
18205            @Override
18206            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
18207                    long groupId, long folderId, int status,
18208                    OrderByComparator orderByComparator)
18209                    throws NoSuchArticleException, SystemException {
18210                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18211                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
18212                                    orderByComparator);
18213                    }
18214    
18215                    JournalArticle journalArticle = findByPrimaryKey(id);
18216    
18217                    Session session = null;
18218    
18219                    try {
18220                            session = openSession();
18221    
18222                            JournalArticle[] array = new JournalArticleImpl[3];
18223    
18224                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
18225                                            groupId, folderId, status, orderByComparator, true);
18226    
18227                            array[1] = journalArticle;
18228    
18229                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
18230                                            groupId, folderId, status, orderByComparator, false);
18231    
18232                            return array;
18233                    }
18234                    catch (Exception e) {
18235                            throw processException(e);
18236                    }
18237                    finally {
18238                            closeSession(session);
18239                    }
18240            }
18241    
18242            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
18243                    JournalArticle journalArticle, long groupId, long folderId, int status,
18244                    OrderByComparator orderByComparator, boolean previous) {
18245                    StringBundler query = null;
18246    
18247                    if (orderByComparator != null) {
18248                            query = new StringBundler(6 +
18249                                            (orderByComparator.getOrderByFields().length * 6));
18250                    }
18251                    else {
18252                            query = new StringBundler(3);
18253                    }
18254    
18255                    if (getDB().isSupportsInlineDistinct()) {
18256                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18257                    }
18258                    else {
18259                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18260                    }
18261    
18262                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
18263    
18264                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
18265    
18266                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
18267    
18268                    if (!getDB().isSupportsInlineDistinct()) {
18269                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18270                    }
18271    
18272                    if (orderByComparator != null) {
18273                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18274    
18275                            if (orderByConditionFields.length > 0) {
18276                                    query.append(WHERE_AND);
18277                            }
18278    
18279                            for (int i = 0; i < orderByConditionFields.length; i++) {
18280                                    if (getDB().isSupportsInlineDistinct()) {
18281                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18282                                    }
18283                                    else {
18284                                            query.append(_ORDER_BY_ENTITY_TABLE);
18285                                    }
18286    
18287                                    query.append(orderByConditionFields[i]);
18288    
18289                                    if ((i + 1) < orderByConditionFields.length) {
18290                                            if (orderByComparator.isAscending() ^ previous) {
18291                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18292                                            }
18293                                            else {
18294                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18295                                            }
18296                                    }
18297                                    else {
18298                                            if (orderByComparator.isAscending() ^ previous) {
18299                                                    query.append(WHERE_GREATER_THAN);
18300                                            }
18301                                            else {
18302                                                    query.append(WHERE_LESSER_THAN);
18303                                            }
18304                                    }
18305                            }
18306    
18307                            query.append(ORDER_BY_CLAUSE);
18308    
18309                            String[] orderByFields = orderByComparator.getOrderByFields();
18310    
18311                            for (int i = 0; i < orderByFields.length; i++) {
18312                                    if (getDB().isSupportsInlineDistinct()) {
18313                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18314                                    }
18315                                    else {
18316                                            query.append(_ORDER_BY_ENTITY_TABLE);
18317                                    }
18318    
18319                                    query.append(orderByFields[i]);
18320    
18321                                    if ((i + 1) < orderByFields.length) {
18322                                            if (orderByComparator.isAscending() ^ previous) {
18323                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18324                                            }
18325                                            else {
18326                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18327                                            }
18328                                    }
18329                                    else {
18330                                            if (orderByComparator.isAscending() ^ previous) {
18331                                                    query.append(ORDER_BY_ASC);
18332                                            }
18333                                            else {
18334                                                    query.append(ORDER_BY_DESC);
18335                                            }
18336                                    }
18337                            }
18338                    }
18339                    else {
18340                            if (getDB().isSupportsInlineDistinct()) {
18341                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18342                            }
18343                            else {
18344                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18345                            }
18346                    }
18347    
18348                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18349                                    JournalArticle.class.getName(),
18350                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18351    
18352                    SQLQuery q = session.createSQLQuery(sql);
18353    
18354                    q.setFirstResult(0);
18355                    q.setMaxResults(2);
18356    
18357                    if (getDB().isSupportsInlineDistinct()) {
18358                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18359                    }
18360                    else {
18361                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18362                    }
18363    
18364                    QueryPos qPos = QueryPos.getInstance(q);
18365    
18366                    qPos.add(groupId);
18367    
18368                    qPos.add(folderId);
18369    
18370                    qPos.add(status);
18371    
18372                    if (orderByComparator != null) {
18373                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18374    
18375                            for (Object value : values) {
18376                                    qPos.add(value);
18377                            }
18378                    }
18379    
18380                    List<JournalArticle> list = q.list();
18381    
18382                    if (list.size() == 2) {
18383                            return list.get(1);
18384                    }
18385                    else {
18386                            return null;
18387                    }
18388            }
18389    
18390            /**
18391             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
18392             *
18393             * @param groupId the group ID
18394             * @param folderId the folder ID
18395             * @param statuses the statuses
18396             * @return the matching journal articles that the user has permission to view
18397             * @throws SystemException if a system exception occurred
18398             */
18399            @Override
18400            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
18401                    int[] statuses) throws SystemException {
18402                    return filterFindByG_F_ST(groupId, folderId, statuses,
18403                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18404            }
18405    
18406            /**
18407             * 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;.
18408             *
18409             * <p>
18410             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18411             * </p>
18412             *
18413             * @param groupId the group ID
18414             * @param folderId the folder ID
18415             * @param statuses the statuses
18416             * @param start the lower bound of the range of journal articles
18417             * @param end the upper bound of the range of journal articles (not inclusive)
18418             * @return the range of matching journal articles that the user has permission to view
18419             * @throws SystemException if a system exception occurred
18420             */
18421            @Override
18422            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
18423                    int[] statuses, int start, int end) throws SystemException {
18424                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
18425            }
18426    
18427            /**
18428             * 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;.
18429             *
18430             * <p>
18431             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18432             * </p>
18433             *
18434             * @param groupId the group ID
18435             * @param folderId the folder ID
18436             * @param statuses the statuses
18437             * @param start the lower bound of the range of journal articles
18438             * @param end the upper bound of the range of journal articles (not inclusive)
18439             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18440             * @return the ordered range of matching journal articles that the user has permission to view
18441             * @throws SystemException if a system exception occurred
18442             */
18443            @Override
18444            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
18445                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
18446                    throws SystemException {
18447                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18448                            return findByG_F_ST(groupId, folderId, statuses, start, end,
18449                                    orderByComparator);
18450                    }
18451    
18452                    StringBundler query = new StringBundler();
18453    
18454                    if (getDB().isSupportsInlineDistinct()) {
18455                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18456                    }
18457                    else {
18458                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18459                    }
18460    
18461                    boolean conjunctionable = false;
18462    
18463                    if (conjunctionable) {
18464                            query.append(WHERE_AND);
18465                    }
18466    
18467                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
18468    
18469                    conjunctionable = true;
18470    
18471                    if (conjunctionable) {
18472                            query.append(WHERE_AND);
18473                    }
18474    
18475                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
18476    
18477                    conjunctionable = true;
18478    
18479                    if ((statuses == null) || (statuses.length > 0)) {
18480                            if (conjunctionable) {
18481                                    query.append(WHERE_AND);
18482                            }
18483    
18484                            query.append(StringPool.OPEN_PARENTHESIS);
18485    
18486                            for (int i = 0; i < statuses.length; i++) {
18487                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
18488    
18489                                    if ((i + 1) < statuses.length) {
18490                                            query.append(WHERE_OR);
18491                                    }
18492                            }
18493    
18494                            query.append(StringPool.CLOSE_PARENTHESIS);
18495    
18496                            conjunctionable = true;
18497                    }
18498    
18499                    if (!getDB().isSupportsInlineDistinct()) {
18500                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18501                    }
18502    
18503                    if (orderByComparator != null) {
18504                            if (getDB().isSupportsInlineDistinct()) {
18505                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18506                                            orderByComparator, true);
18507                            }
18508                            else {
18509                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18510                                            orderByComparator, true);
18511                            }
18512                    }
18513                    else {
18514                            if (getDB().isSupportsInlineDistinct()) {
18515                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18516                            }
18517                            else {
18518                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18519                            }
18520                    }
18521    
18522                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18523                                    JournalArticle.class.getName(),
18524                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18525    
18526                    Session session = null;
18527    
18528                    try {
18529                            session = openSession();
18530    
18531                            SQLQuery q = session.createSQLQuery(sql);
18532    
18533                            if (getDB().isSupportsInlineDistinct()) {
18534                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18535                            }
18536                            else {
18537                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18538                            }
18539    
18540                            QueryPos qPos = QueryPos.getInstance(q);
18541    
18542                            qPos.add(groupId);
18543    
18544                            qPos.add(folderId);
18545    
18546                            if (statuses != null) {
18547                                    qPos.add(statuses);
18548                            }
18549    
18550                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18551                                    end);
18552                    }
18553                    catch (Exception e) {
18554                            throw processException(e);
18555                    }
18556                    finally {
18557                            closeSession(session);
18558                    }
18559            }
18560    
18561            /**
18562             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18563             *
18564             * <p>
18565             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18566             * </p>
18567             *
18568             * @param groupId the group ID
18569             * @param folderId the folder ID
18570             * @param statuses the statuses
18571             * @return the matching journal articles
18572             * @throws SystemException if a system exception occurred
18573             */
18574            @Override
18575            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
18576                    int[] statuses) throws SystemException {
18577                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
18578                            QueryUtil.ALL_POS, null);
18579            }
18580    
18581            /**
18582             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18583             *
18584             * <p>
18585             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18586             * </p>
18587             *
18588             * @param groupId the group ID
18589             * @param folderId the folder ID
18590             * @param statuses the statuses
18591             * @param start the lower bound of the range of journal articles
18592             * @param end the upper bound of the range of journal articles (not inclusive)
18593             * @return the range of matching journal articles
18594             * @throws SystemException if a system exception occurred
18595             */
18596            @Override
18597            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
18598                    int[] statuses, int start, int end) throws SystemException {
18599                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
18600            }
18601    
18602            /**
18603             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18604             *
18605             * <p>
18606             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18607             * </p>
18608             *
18609             * @param groupId the group ID
18610             * @param folderId the folder ID
18611             * @param statuses the statuses
18612             * @param start the lower bound of the range of journal articles
18613             * @param end the upper bound of the range of journal articles (not inclusive)
18614             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18615             * @return the ordered range of matching journal articles
18616             * @throws SystemException if a system exception occurred
18617             */
18618            @Override
18619            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
18620                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
18621                    throws SystemException {
18622                    if ((statuses != null) && (statuses.length == 1)) {
18623                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
18624                                    orderByComparator);
18625                    }
18626    
18627                    boolean pagination = true;
18628                    Object[] finderArgs = null;
18629    
18630                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18631                                    (orderByComparator == null)) {
18632                            pagination = false;
18633                            finderArgs = new Object[] {
18634                                            groupId, folderId, StringUtil.merge(statuses)
18635                                    };
18636                    }
18637                    else {
18638                            finderArgs = new Object[] {
18639                                            groupId, folderId, StringUtil.merge(statuses),
18640                                            
18641                                            start, end, orderByComparator
18642                                    };
18643                    }
18644    
18645                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
18646                                    finderArgs, this);
18647    
18648                    if ((list != null) && !list.isEmpty()) {
18649                            for (JournalArticle journalArticle : list) {
18650                                    if ((groupId != journalArticle.getGroupId()) ||
18651                                                    (folderId != journalArticle.getFolderId()) ||
18652                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
18653                                            list = null;
18654    
18655                                            break;
18656                                    }
18657                            }
18658                    }
18659    
18660                    if (list == null) {
18661                            StringBundler query = new StringBundler();
18662    
18663                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18664    
18665                            boolean conjunctionable = false;
18666    
18667                            if (conjunctionable) {
18668                                    query.append(WHERE_AND);
18669                            }
18670    
18671                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
18672    
18673                            conjunctionable = true;
18674    
18675                            if (conjunctionable) {
18676                                    query.append(WHERE_AND);
18677                            }
18678    
18679                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
18680    
18681                            conjunctionable = true;
18682    
18683                            if ((statuses == null) || (statuses.length > 0)) {
18684                                    if (conjunctionable) {
18685                                            query.append(WHERE_AND);
18686                                    }
18687    
18688                                    query.append(StringPool.OPEN_PARENTHESIS);
18689    
18690                                    for (int i = 0; i < statuses.length; i++) {
18691                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
18692    
18693                                            if ((i + 1) < statuses.length) {
18694                                                    query.append(WHERE_OR);
18695                                            }
18696                                    }
18697    
18698                                    query.append(StringPool.CLOSE_PARENTHESIS);
18699    
18700                                    conjunctionable = true;
18701                            }
18702    
18703                            if (orderByComparator != null) {
18704                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18705                                            orderByComparator);
18706                            }
18707                            else
18708                             if (pagination) {
18709                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18710                            }
18711    
18712                            String sql = query.toString();
18713    
18714                            Session session = null;
18715    
18716                            try {
18717                                    session = openSession();
18718    
18719                                    Query q = session.createQuery(sql);
18720    
18721                                    QueryPos qPos = QueryPos.getInstance(q);
18722    
18723                                    qPos.add(groupId);
18724    
18725                                    qPos.add(folderId);
18726    
18727                                    if (statuses != null) {
18728                                            qPos.add(statuses);
18729                                    }
18730    
18731                                    if (!pagination) {
18732                                            list = (List<JournalArticle>)QueryUtil.list(q,
18733                                                            getDialect(), start, end, false);
18734    
18735                                            Collections.sort(list);
18736    
18737                                            list = new UnmodifiableList<JournalArticle>(list);
18738                                    }
18739                                    else {
18740                                            list = (List<JournalArticle>)QueryUtil.list(q,
18741                                                            getDialect(), start, end);
18742                                    }
18743    
18744                                    cacheResult(list);
18745    
18746                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
18747                                            finderArgs, list);
18748                            }
18749                            catch (Exception e) {
18750                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
18751                                            finderArgs);
18752    
18753                                    throw processException(e);
18754                            }
18755                            finally {
18756                                    closeSession(session);
18757                            }
18758                    }
18759    
18760                    return list;
18761            }
18762    
18763            /**
18764             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
18765             *
18766             * @param groupId the group ID
18767             * @param folderId the folder ID
18768             * @param status the status
18769             * @throws SystemException if a system exception occurred
18770             */
18771            @Override
18772            public void removeByG_F_ST(long groupId, long folderId, int status)
18773                    throws SystemException {
18774                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
18775                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18776                            remove(journalArticle);
18777                    }
18778            }
18779    
18780            /**
18781             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
18782             *
18783             * @param groupId the group ID
18784             * @param folderId the folder ID
18785             * @param status the status
18786             * @return the number of matching journal articles
18787             * @throws SystemException if a system exception occurred
18788             */
18789            @Override
18790            public int countByG_F_ST(long groupId, long folderId, int status)
18791                    throws SystemException {
18792                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
18793    
18794                    Object[] finderArgs = new Object[] { groupId, folderId, status };
18795    
18796                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18797                                    this);
18798    
18799                    if (count == null) {
18800                            StringBundler query = new StringBundler(4);
18801    
18802                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18803    
18804                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
18805    
18806                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
18807    
18808                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
18809    
18810                            String sql = query.toString();
18811    
18812                            Session session = null;
18813    
18814                            try {
18815                                    session = openSession();
18816    
18817                                    Query q = session.createQuery(sql);
18818    
18819                                    QueryPos qPos = QueryPos.getInstance(q);
18820    
18821                                    qPos.add(groupId);
18822    
18823                                    qPos.add(folderId);
18824    
18825                                    qPos.add(status);
18826    
18827                                    count = (Long)q.uniqueResult();
18828    
18829                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18830                            }
18831                            catch (Exception e) {
18832                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18833    
18834                                    throw processException(e);
18835                            }
18836                            finally {
18837                                    closeSession(session);
18838                            }
18839                    }
18840    
18841                    return count.intValue();
18842            }
18843    
18844            /**
18845             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18846             *
18847             * @param groupId the group ID
18848             * @param folderId the folder ID
18849             * @param statuses the statuses
18850             * @return the number of matching journal articles
18851             * @throws SystemException if a system exception occurred
18852             */
18853            @Override
18854            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
18855                    throws SystemException {
18856                    Object[] finderArgs = new Object[] {
18857                                    groupId, folderId, StringUtil.merge(statuses)
18858                            };
18859    
18860                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
18861                                    finderArgs, this);
18862    
18863                    if (count == null) {
18864                            StringBundler query = new StringBundler();
18865    
18866                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18867    
18868                            boolean conjunctionable = false;
18869    
18870                            if (conjunctionable) {
18871                                    query.append(WHERE_AND);
18872                            }
18873    
18874                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
18875    
18876                            conjunctionable = true;
18877    
18878                            if (conjunctionable) {
18879                                    query.append(WHERE_AND);
18880                            }
18881    
18882                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
18883    
18884                            conjunctionable = true;
18885    
18886                            if ((statuses == null) || (statuses.length > 0)) {
18887                                    if (conjunctionable) {
18888                                            query.append(WHERE_AND);
18889                                    }
18890    
18891                                    query.append(StringPool.OPEN_PARENTHESIS);
18892    
18893                                    for (int i = 0; i < statuses.length; i++) {
18894                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
18895    
18896                                            if ((i + 1) < statuses.length) {
18897                                                    query.append(WHERE_OR);
18898                                            }
18899                                    }
18900    
18901                                    query.append(StringPool.CLOSE_PARENTHESIS);
18902    
18903                                    conjunctionable = true;
18904                            }
18905    
18906                            String sql = query.toString();
18907    
18908                            Session session = null;
18909    
18910                            try {
18911                                    session = openSession();
18912    
18913                                    Query q = session.createQuery(sql);
18914    
18915                                    QueryPos qPos = QueryPos.getInstance(q);
18916    
18917                                    qPos.add(groupId);
18918    
18919                                    qPos.add(folderId);
18920    
18921                                    if (statuses != null) {
18922                                            qPos.add(statuses);
18923                                    }
18924    
18925                                    count = (Long)q.uniqueResult();
18926    
18927                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
18928                                            finderArgs, count);
18929                            }
18930                            catch (Exception e) {
18931                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
18932                                            finderArgs);
18933    
18934                                    throw processException(e);
18935                            }
18936                            finally {
18937                                    closeSession(session);
18938                            }
18939                    }
18940    
18941                    return count.intValue();
18942            }
18943    
18944            /**
18945             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
18946             *
18947             * @param groupId the group ID
18948             * @param folderId the folder ID
18949             * @param status the status
18950             * @return the number of matching journal articles that the user has permission to view
18951             * @throws SystemException if a system exception occurred
18952             */
18953            @Override
18954            public int filterCountByG_F_ST(long groupId, long folderId, int status)
18955                    throws SystemException {
18956                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18957                            return countByG_F_ST(groupId, folderId, status);
18958                    }
18959    
18960                    StringBundler query = new StringBundler(4);
18961    
18962                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18963    
18964                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
18965    
18966                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
18967    
18968                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
18969    
18970                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18971                                    JournalArticle.class.getName(),
18972                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18973    
18974                    Session session = null;
18975    
18976                    try {
18977                            session = openSession();
18978    
18979                            SQLQuery q = session.createSQLQuery(sql);
18980    
18981                            q.addScalar(COUNT_COLUMN_NAME,
18982                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18983    
18984                            QueryPos qPos = QueryPos.getInstance(q);
18985    
18986                            qPos.add(groupId);
18987    
18988                            qPos.add(folderId);
18989    
18990                            qPos.add(status);
18991    
18992                            Long count = (Long)q.uniqueResult();
18993    
18994                            return count.intValue();
18995                    }
18996                    catch (Exception e) {
18997                            throw processException(e);
18998                    }
18999                    finally {
19000                            closeSession(session);
19001                    }
19002            }
19003    
19004            /**
19005             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
19006             *
19007             * @param groupId the group ID
19008             * @param folderId the folder ID
19009             * @param statuses the statuses
19010             * @return the number of matching journal articles that the user has permission to view
19011             * @throws SystemException if a system exception occurred
19012             */
19013            @Override
19014            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
19015                    throws SystemException {
19016                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19017                            return countByG_F_ST(groupId, folderId, statuses);
19018                    }
19019    
19020                    StringBundler query = new StringBundler();
19021    
19022                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19023    
19024                    boolean conjunctionable = false;
19025    
19026                    if (conjunctionable) {
19027                            query.append(WHERE_AND);
19028                    }
19029    
19030                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
19031    
19032                    conjunctionable = true;
19033    
19034                    if (conjunctionable) {
19035                            query.append(WHERE_AND);
19036                    }
19037    
19038                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
19039    
19040                    conjunctionable = true;
19041    
19042                    if ((statuses == null) || (statuses.length > 0)) {
19043                            if (conjunctionable) {
19044                                    query.append(WHERE_AND);
19045                            }
19046    
19047                            query.append(StringPool.OPEN_PARENTHESIS);
19048    
19049                            for (int i = 0; i < statuses.length; i++) {
19050                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
19051    
19052                                    if ((i + 1) < statuses.length) {
19053                                            query.append(WHERE_OR);
19054                                    }
19055                            }
19056    
19057                            query.append(StringPool.CLOSE_PARENTHESIS);
19058    
19059                            conjunctionable = true;
19060                    }
19061    
19062                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19063                                    JournalArticle.class.getName(),
19064                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19065    
19066                    Session session = null;
19067    
19068                    try {
19069                            session = openSession();
19070    
19071                            SQLQuery q = session.createSQLQuery(sql);
19072    
19073                            q.addScalar(COUNT_COLUMN_NAME,
19074                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19075    
19076                            QueryPos qPos = QueryPos.getInstance(q);
19077    
19078                            qPos.add(groupId);
19079    
19080                            qPos.add(folderId);
19081    
19082                            if (statuses != null) {
19083                                    qPos.add(statuses);
19084                            }
19085    
19086                            Long count = (Long)q.uniqueResult();
19087    
19088                            return count.intValue();
19089                    }
19090                    catch (Exception e) {
19091                            throw processException(e);
19092                    }
19093                    finally {
19094                            closeSession(session);
19095                    }
19096            }
19097    
19098            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
19099            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
19100                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
19101            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
19102            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
19103                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
19104            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
19105            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
19106                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
19107            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19108                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19109                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19110                            "findByG_C_C",
19111                            new String[] {
19112                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
19113                                    
19114                            Integer.class.getName(), Integer.class.getName(),
19115                                    OrderByComparator.class.getName()
19116                            });
19117            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19118                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19119                            JournalArticleImpl.class,
19120                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
19121                            new String[] {
19122                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
19123                            },
19124                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19125                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
19126                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
19127                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19128                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19129            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19130                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19131                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
19132                            new String[] {
19133                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
19134                            });
19135    
19136            /**
19137             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19138             *
19139             * @param groupId the group ID
19140             * @param classNameId the class name ID
19141             * @param classPK the class p k
19142             * @return the matching journal articles
19143             * @throws SystemException if a system exception occurred
19144             */
19145            @Override
19146            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
19147                    long classPK) throws SystemException {
19148                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
19149                            QueryUtil.ALL_POS, null);
19150            }
19151    
19152            /**
19153             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19154             *
19155             * <p>
19156             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19157             * </p>
19158             *
19159             * @param groupId the group ID
19160             * @param classNameId the class name ID
19161             * @param classPK the class p k
19162             * @param start the lower bound of the range of journal articles
19163             * @param end the upper bound of the range of journal articles (not inclusive)
19164             * @return the range of matching journal articles
19165             * @throws SystemException if a system exception occurred
19166             */
19167            @Override
19168            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
19169                    long classPK, int start, int end) throws SystemException {
19170                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
19171            }
19172    
19173            /**
19174             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19175             *
19176             * <p>
19177             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19178             * </p>
19179             *
19180             * @param groupId the group ID
19181             * @param classNameId the class name ID
19182             * @param classPK the class p k
19183             * @param start the lower bound of the range of journal articles
19184             * @param end the upper bound of the range of journal articles (not inclusive)
19185             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19186             * @return the ordered range of matching journal articles
19187             * @throws SystemException if a system exception occurred
19188             */
19189            @Override
19190            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
19191                    long classPK, int start, int end, OrderByComparator orderByComparator)
19192                    throws SystemException {
19193                    boolean pagination = true;
19194                    FinderPath finderPath = null;
19195                    Object[] finderArgs = null;
19196    
19197                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19198                                    (orderByComparator == null)) {
19199                            pagination = false;
19200                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
19201                            finderArgs = new Object[] { groupId, classNameId, classPK };
19202                    }
19203                    else {
19204                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
19205                            finderArgs = new Object[] {
19206                                            groupId, classNameId, classPK,
19207                                            
19208                                            start, end, orderByComparator
19209                                    };
19210                    }
19211    
19212                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19213                                    finderArgs, this);
19214    
19215                    if ((list != null) && !list.isEmpty()) {
19216                            for (JournalArticle journalArticle : list) {
19217                                    if ((groupId != journalArticle.getGroupId()) ||
19218                                                    (classNameId != journalArticle.getClassNameId()) ||
19219                                                    (classPK != journalArticle.getClassPK())) {
19220                                            list = null;
19221    
19222                                            break;
19223                                    }
19224                            }
19225                    }
19226    
19227                    if (list == null) {
19228                            StringBundler query = null;
19229    
19230                            if (orderByComparator != null) {
19231                                    query = new StringBundler(5 +
19232                                                    (orderByComparator.getOrderByFields().length * 3));
19233                            }
19234                            else {
19235                                    query = new StringBundler(5);
19236                            }
19237    
19238                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19239    
19240                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19241    
19242                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19243    
19244                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19245    
19246                            if (orderByComparator != null) {
19247                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19248                                            orderByComparator);
19249                            }
19250                            else
19251                             if (pagination) {
19252                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19253                            }
19254    
19255                            String sql = query.toString();
19256    
19257                            Session session = null;
19258    
19259                            try {
19260                                    session = openSession();
19261    
19262                                    Query q = session.createQuery(sql);
19263    
19264                                    QueryPos qPos = QueryPos.getInstance(q);
19265    
19266                                    qPos.add(groupId);
19267    
19268                                    qPos.add(classNameId);
19269    
19270                                    qPos.add(classPK);
19271    
19272                                    if (!pagination) {
19273                                            list = (List<JournalArticle>)QueryUtil.list(q,
19274                                                            getDialect(), start, end, false);
19275    
19276                                            Collections.sort(list);
19277    
19278                                            list = new UnmodifiableList<JournalArticle>(list);
19279                                    }
19280                                    else {
19281                                            list = (List<JournalArticle>)QueryUtil.list(q,
19282                                                            getDialect(), start, end);
19283                                    }
19284    
19285                                    cacheResult(list);
19286    
19287                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19288                            }
19289                            catch (Exception e) {
19290                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19291    
19292                                    throw processException(e);
19293                            }
19294                            finally {
19295                                    closeSession(session);
19296                            }
19297                    }
19298    
19299                    return list;
19300            }
19301    
19302            /**
19303             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19304             *
19305             * @param groupId the group ID
19306             * @param classNameId the class name ID
19307             * @param classPK the class p k
19308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19309             * @return the first matching journal article
19310             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19311             * @throws SystemException if a system exception occurred
19312             */
19313            @Override
19314            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
19315                    long classPK, OrderByComparator orderByComparator)
19316                    throws NoSuchArticleException, SystemException {
19317                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
19318                                    classNameId, classPK, orderByComparator);
19319    
19320                    if (journalArticle != null) {
19321                            return journalArticle;
19322                    }
19323    
19324                    StringBundler msg = new StringBundler(8);
19325    
19326                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19327    
19328                    msg.append("groupId=");
19329                    msg.append(groupId);
19330    
19331                    msg.append(", classNameId=");
19332                    msg.append(classNameId);
19333    
19334                    msg.append(", classPK=");
19335                    msg.append(classPK);
19336    
19337                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19338    
19339                    throw new NoSuchArticleException(msg.toString());
19340            }
19341    
19342            /**
19343             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19344             *
19345             * @param groupId the group ID
19346             * @param classNameId the class name ID
19347             * @param classPK the class p k
19348             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19349             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19350             * @throws SystemException if a system exception occurred
19351             */
19352            @Override
19353            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
19354                    long classPK, OrderByComparator orderByComparator)
19355                    throws SystemException {
19356                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
19357                                    0, 1, orderByComparator);
19358    
19359                    if (!list.isEmpty()) {
19360                            return list.get(0);
19361                    }
19362    
19363                    return null;
19364            }
19365    
19366            /**
19367             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19368             *
19369             * @param groupId the group ID
19370             * @param classNameId the class name ID
19371             * @param classPK the class p k
19372             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19373             * @return the last matching journal article
19374             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19375             * @throws SystemException if a system exception occurred
19376             */
19377            @Override
19378            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
19379                    long classPK, OrderByComparator orderByComparator)
19380                    throws NoSuchArticleException, SystemException {
19381                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
19382                                    classPK, orderByComparator);
19383    
19384                    if (journalArticle != null) {
19385                            return journalArticle;
19386                    }
19387    
19388                    StringBundler msg = new StringBundler(8);
19389    
19390                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19391    
19392                    msg.append("groupId=");
19393                    msg.append(groupId);
19394    
19395                    msg.append(", classNameId=");
19396                    msg.append(classNameId);
19397    
19398                    msg.append(", classPK=");
19399                    msg.append(classPK);
19400    
19401                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19402    
19403                    throw new NoSuchArticleException(msg.toString());
19404            }
19405    
19406            /**
19407             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19408             *
19409             * @param groupId the group ID
19410             * @param classNameId the class name ID
19411             * @param classPK the class p k
19412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19413             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19414             * @throws SystemException if a system exception occurred
19415             */
19416            @Override
19417            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
19418                    long classPK, OrderByComparator orderByComparator)
19419                    throws SystemException {
19420                    int count = countByG_C_C(groupId, classNameId, classPK);
19421    
19422                    if (count == 0) {
19423                            return null;
19424                    }
19425    
19426                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
19427                                    count - 1, count, orderByComparator);
19428    
19429                    if (!list.isEmpty()) {
19430                            return list.get(0);
19431                    }
19432    
19433                    return null;
19434            }
19435    
19436            /**
19437             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19438             *
19439             * @param id the primary key of the current journal article
19440             * @param groupId the group ID
19441             * @param classNameId the class name ID
19442             * @param classPK the class p k
19443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19444             * @return the previous, current, and next journal article
19445             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19446             * @throws SystemException if a system exception occurred
19447             */
19448            @Override
19449            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
19450                    long classNameId, long classPK, OrderByComparator orderByComparator)
19451                    throws NoSuchArticleException, SystemException {
19452                    JournalArticle journalArticle = findByPrimaryKey(id);
19453    
19454                    Session session = null;
19455    
19456                    try {
19457                            session = openSession();
19458    
19459                            JournalArticle[] array = new JournalArticleImpl[3];
19460    
19461                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
19462                                            classNameId, classPK, orderByComparator, true);
19463    
19464                            array[1] = journalArticle;
19465    
19466                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
19467                                            classNameId, classPK, orderByComparator, false);
19468    
19469                            return array;
19470                    }
19471                    catch (Exception e) {
19472                            throw processException(e);
19473                    }
19474                    finally {
19475                            closeSession(session);
19476                    }
19477            }
19478    
19479            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
19480                    JournalArticle journalArticle, long groupId, long classNameId,
19481                    long classPK, OrderByComparator orderByComparator, boolean previous) {
19482                    StringBundler query = null;
19483    
19484                    if (orderByComparator != null) {
19485                            query = new StringBundler(6 +
19486                                            (orderByComparator.getOrderByFields().length * 6));
19487                    }
19488                    else {
19489                            query = new StringBundler(3);
19490                    }
19491    
19492                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19493    
19494                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19495    
19496                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19497    
19498                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19499    
19500                    if (orderByComparator != null) {
19501                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19502    
19503                            if (orderByConditionFields.length > 0) {
19504                                    query.append(WHERE_AND);
19505                            }
19506    
19507                            for (int i = 0; i < orderByConditionFields.length; i++) {
19508                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19509                                    query.append(orderByConditionFields[i]);
19510    
19511                                    if ((i + 1) < orderByConditionFields.length) {
19512                                            if (orderByComparator.isAscending() ^ previous) {
19513                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19514                                            }
19515                                            else {
19516                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19517                                            }
19518                                    }
19519                                    else {
19520                                            if (orderByComparator.isAscending() ^ previous) {
19521                                                    query.append(WHERE_GREATER_THAN);
19522                                            }
19523                                            else {
19524                                                    query.append(WHERE_LESSER_THAN);
19525                                            }
19526                                    }
19527                            }
19528    
19529                            query.append(ORDER_BY_CLAUSE);
19530    
19531                            String[] orderByFields = orderByComparator.getOrderByFields();
19532    
19533                            for (int i = 0; i < orderByFields.length; i++) {
19534                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19535                                    query.append(orderByFields[i]);
19536    
19537                                    if ((i + 1) < orderByFields.length) {
19538                                            if (orderByComparator.isAscending() ^ previous) {
19539                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19540                                            }
19541                                            else {
19542                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19543                                            }
19544                                    }
19545                                    else {
19546                                            if (orderByComparator.isAscending() ^ previous) {
19547                                                    query.append(ORDER_BY_ASC);
19548                                            }
19549                                            else {
19550                                                    query.append(ORDER_BY_DESC);
19551                                            }
19552                                    }
19553                            }
19554                    }
19555                    else {
19556                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19557                    }
19558    
19559                    String sql = query.toString();
19560    
19561                    Query q = session.createQuery(sql);
19562    
19563                    q.setFirstResult(0);
19564                    q.setMaxResults(2);
19565    
19566                    QueryPos qPos = QueryPos.getInstance(q);
19567    
19568                    qPos.add(groupId);
19569    
19570                    qPos.add(classNameId);
19571    
19572                    qPos.add(classPK);
19573    
19574                    if (orderByComparator != null) {
19575                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19576    
19577                            for (Object value : values) {
19578                                    qPos.add(value);
19579                            }
19580                    }
19581    
19582                    List<JournalArticle> list = q.list();
19583    
19584                    if (list.size() == 2) {
19585                            return list.get(1);
19586                    }
19587                    else {
19588                            return null;
19589                    }
19590            }
19591    
19592            /**
19593             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19594             *
19595             * @param groupId the group ID
19596             * @param classNameId the class name ID
19597             * @param classPK the class p k
19598             * @return the matching journal articles that the user has permission to view
19599             * @throws SystemException if a system exception occurred
19600             */
19601            @Override
19602            public List<JournalArticle> filterFindByG_C_C(long groupId,
19603                    long classNameId, long classPK) throws SystemException {
19604                    return filterFindByG_C_C(groupId, classNameId, classPK,
19605                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19606            }
19607    
19608            /**
19609             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19610             *
19611             * <p>
19612             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19613             * </p>
19614             *
19615             * @param groupId the group ID
19616             * @param classNameId the class name ID
19617             * @param classPK the class p k
19618             * @param start the lower bound of the range of journal articles
19619             * @param end the upper bound of the range of journal articles (not inclusive)
19620             * @return the range of matching journal articles that the user has permission to view
19621             * @throws SystemException if a system exception occurred
19622             */
19623            @Override
19624            public List<JournalArticle> filterFindByG_C_C(long groupId,
19625                    long classNameId, long classPK, int start, int end)
19626                    throws SystemException {
19627                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
19628            }
19629    
19630            /**
19631             * 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;.
19632             *
19633             * <p>
19634             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19635             * </p>
19636             *
19637             * @param groupId the group ID
19638             * @param classNameId the class name ID
19639             * @param classPK the class p k
19640             * @param start the lower bound of the range of journal articles
19641             * @param end the upper bound of the range of journal articles (not inclusive)
19642             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19643             * @return the ordered range of matching journal articles that the user has permission to view
19644             * @throws SystemException if a system exception occurred
19645             */
19646            @Override
19647            public List<JournalArticle> filterFindByG_C_C(long groupId,
19648                    long classNameId, long classPK, int start, int end,
19649                    OrderByComparator orderByComparator) throws SystemException {
19650                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19651                            return findByG_C_C(groupId, classNameId, classPK, start, end,
19652                                    orderByComparator);
19653                    }
19654    
19655                    StringBundler query = null;
19656    
19657                    if (orderByComparator != null) {
19658                            query = new StringBundler(5 +
19659                                            (orderByComparator.getOrderByFields().length * 3));
19660                    }
19661                    else {
19662                            query = new StringBundler(5);
19663                    }
19664    
19665                    if (getDB().isSupportsInlineDistinct()) {
19666                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19667                    }
19668                    else {
19669                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19670                    }
19671    
19672                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19673    
19674                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19675    
19676                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19677    
19678                    if (!getDB().isSupportsInlineDistinct()) {
19679                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19680                    }
19681    
19682                    if (orderByComparator != null) {
19683                            if (getDB().isSupportsInlineDistinct()) {
19684                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19685                                            orderByComparator, true);
19686                            }
19687                            else {
19688                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19689                                            orderByComparator, true);
19690                            }
19691                    }
19692                    else {
19693                            if (getDB().isSupportsInlineDistinct()) {
19694                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19695                            }
19696                            else {
19697                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19698                            }
19699                    }
19700    
19701                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19702                                    JournalArticle.class.getName(),
19703                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19704    
19705                    Session session = null;
19706    
19707                    try {
19708                            session = openSession();
19709    
19710                            SQLQuery q = session.createSQLQuery(sql);
19711    
19712                            if (getDB().isSupportsInlineDistinct()) {
19713                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19714                            }
19715                            else {
19716                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19717                            }
19718    
19719                            QueryPos qPos = QueryPos.getInstance(q);
19720    
19721                            qPos.add(groupId);
19722    
19723                            qPos.add(classNameId);
19724    
19725                            qPos.add(classPK);
19726    
19727                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19728                                    end);
19729                    }
19730                    catch (Exception e) {
19731                            throw processException(e);
19732                    }
19733                    finally {
19734                            closeSession(session);
19735                    }
19736            }
19737    
19738            /**
19739             * 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;.
19740             *
19741             * @param id the primary key of the current journal article
19742             * @param groupId the group ID
19743             * @param classNameId the class name ID
19744             * @param classPK the class p k
19745             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19746             * @return the previous, current, and next journal article
19747             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19748             * @throws SystemException if a system exception occurred
19749             */
19750            @Override
19751            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
19752                    long groupId, long classNameId, long classPK,
19753                    OrderByComparator orderByComparator)
19754                    throws NoSuchArticleException, SystemException {
19755                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19756                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
19757                                    orderByComparator);
19758                    }
19759    
19760                    JournalArticle journalArticle = findByPrimaryKey(id);
19761    
19762                    Session session = null;
19763    
19764                    try {
19765                            session = openSession();
19766    
19767                            JournalArticle[] array = new JournalArticleImpl[3];
19768    
19769                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
19770                                            groupId, classNameId, classPK, orderByComparator, true);
19771    
19772                            array[1] = journalArticle;
19773    
19774                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
19775                                            groupId, classNameId, classPK, orderByComparator, false);
19776    
19777                            return array;
19778                    }
19779                    catch (Exception e) {
19780                            throw processException(e);
19781                    }
19782                    finally {
19783                            closeSession(session);
19784                    }
19785            }
19786    
19787            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
19788                    JournalArticle journalArticle, long groupId, long classNameId,
19789                    long classPK, OrderByComparator orderByComparator, boolean previous) {
19790                    StringBundler query = null;
19791    
19792                    if (orderByComparator != null) {
19793                            query = new StringBundler(6 +
19794                                            (orderByComparator.getOrderByFields().length * 6));
19795                    }
19796                    else {
19797                            query = new StringBundler(3);
19798                    }
19799    
19800                    if (getDB().isSupportsInlineDistinct()) {
19801                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19802                    }
19803                    else {
19804                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19805                    }
19806    
19807                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19808    
19809                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19810    
19811                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19812    
19813                    if (!getDB().isSupportsInlineDistinct()) {
19814                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19815                    }
19816    
19817                    if (orderByComparator != null) {
19818                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19819    
19820                            if (orderByConditionFields.length > 0) {
19821                                    query.append(WHERE_AND);
19822                            }
19823    
19824                            for (int i = 0; i < orderByConditionFields.length; i++) {
19825                                    if (getDB().isSupportsInlineDistinct()) {
19826                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19827                                    }
19828                                    else {
19829                                            query.append(_ORDER_BY_ENTITY_TABLE);
19830                                    }
19831    
19832                                    query.append(orderByConditionFields[i]);
19833    
19834                                    if ((i + 1) < orderByConditionFields.length) {
19835                                            if (orderByComparator.isAscending() ^ previous) {
19836                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19837                                            }
19838                                            else {
19839                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19840                                            }
19841                                    }
19842                                    else {
19843                                            if (orderByComparator.isAscending() ^ previous) {
19844                                                    query.append(WHERE_GREATER_THAN);
19845                                            }
19846                                            else {
19847                                                    query.append(WHERE_LESSER_THAN);
19848                                            }
19849                                    }
19850                            }
19851    
19852                            query.append(ORDER_BY_CLAUSE);
19853    
19854                            String[] orderByFields = orderByComparator.getOrderByFields();
19855    
19856                            for (int i = 0; i < orderByFields.length; i++) {
19857                                    if (getDB().isSupportsInlineDistinct()) {
19858                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19859                                    }
19860                                    else {
19861                                            query.append(_ORDER_BY_ENTITY_TABLE);
19862                                    }
19863    
19864                                    query.append(orderByFields[i]);
19865    
19866                                    if ((i + 1) < orderByFields.length) {
19867                                            if (orderByComparator.isAscending() ^ previous) {
19868                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19869                                            }
19870                                            else {
19871                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19872                                            }
19873                                    }
19874                                    else {
19875                                            if (orderByComparator.isAscending() ^ previous) {
19876                                                    query.append(ORDER_BY_ASC);
19877                                            }
19878                                            else {
19879                                                    query.append(ORDER_BY_DESC);
19880                                            }
19881                                    }
19882                            }
19883                    }
19884                    else {
19885                            if (getDB().isSupportsInlineDistinct()) {
19886                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19887                            }
19888                            else {
19889                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19890                            }
19891                    }
19892    
19893                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19894                                    JournalArticle.class.getName(),
19895                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19896    
19897                    SQLQuery q = session.createSQLQuery(sql);
19898    
19899                    q.setFirstResult(0);
19900                    q.setMaxResults(2);
19901    
19902                    if (getDB().isSupportsInlineDistinct()) {
19903                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19904                    }
19905                    else {
19906                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19907                    }
19908    
19909                    QueryPos qPos = QueryPos.getInstance(q);
19910    
19911                    qPos.add(groupId);
19912    
19913                    qPos.add(classNameId);
19914    
19915                    qPos.add(classPK);
19916    
19917                    if (orderByComparator != null) {
19918                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19919    
19920                            for (Object value : values) {
19921                                    qPos.add(value);
19922                            }
19923                    }
19924    
19925                    List<JournalArticle> list = q.list();
19926    
19927                    if (list.size() == 2) {
19928                            return list.get(1);
19929                    }
19930                    else {
19931                            return null;
19932                    }
19933            }
19934    
19935            /**
19936             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
19937             *
19938             * @param groupId the group ID
19939             * @param classNameId the class name ID
19940             * @param classPK the class p k
19941             * @throws SystemException if a system exception occurred
19942             */
19943            @Override
19944            public void removeByG_C_C(long groupId, long classNameId, long classPK)
19945                    throws SystemException {
19946                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
19947                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19948                            remove(journalArticle);
19949                    }
19950            }
19951    
19952            /**
19953             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19954             *
19955             * @param groupId the group ID
19956             * @param classNameId the class name ID
19957             * @param classPK the class p k
19958             * @return the number of matching journal articles
19959             * @throws SystemException if a system exception occurred
19960             */
19961            @Override
19962            public int countByG_C_C(long groupId, long classNameId, long classPK)
19963                    throws SystemException {
19964                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
19965    
19966                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
19967    
19968                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19969                                    this);
19970    
19971                    if (count == null) {
19972                            StringBundler query = new StringBundler(4);
19973    
19974                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19975    
19976                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19977    
19978                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19979    
19980                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19981    
19982                            String sql = query.toString();
19983    
19984                            Session session = null;
19985    
19986                            try {
19987                                    session = openSession();
19988    
19989                                    Query q = session.createQuery(sql);
19990    
19991                                    QueryPos qPos = QueryPos.getInstance(q);
19992    
19993                                    qPos.add(groupId);
19994    
19995                                    qPos.add(classNameId);
19996    
19997                                    qPos.add(classPK);
19998    
19999                                    count = (Long)q.uniqueResult();
20000    
20001                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20002                            }
20003                            catch (Exception e) {
20004                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20005    
20006                                    throw processException(e);
20007                            }
20008                            finally {
20009                                    closeSession(session);
20010                            }
20011                    }
20012    
20013                    return count.intValue();
20014            }
20015    
20016            /**
20017             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20018             *
20019             * @param groupId the group ID
20020             * @param classNameId the class name ID
20021             * @param classPK the class p k
20022             * @return the number of matching journal articles that the user has permission to view
20023             * @throws SystemException if a system exception occurred
20024             */
20025            @Override
20026            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
20027                    throws SystemException {
20028                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20029                            return countByG_C_C(groupId, classNameId, classPK);
20030                    }
20031    
20032                    StringBundler query = new StringBundler(4);
20033    
20034                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20035    
20036                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
20037    
20038                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
20039    
20040                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
20041    
20042                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20043                                    JournalArticle.class.getName(),
20044                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20045    
20046                    Session session = null;
20047    
20048                    try {
20049                            session = openSession();
20050    
20051                            SQLQuery q = session.createSQLQuery(sql);
20052    
20053                            q.addScalar(COUNT_COLUMN_NAME,
20054                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20055    
20056                            QueryPos qPos = QueryPos.getInstance(q);
20057    
20058                            qPos.add(groupId);
20059    
20060                            qPos.add(classNameId);
20061    
20062                            qPos.add(classPK);
20063    
20064                            Long count = (Long)q.uniqueResult();
20065    
20066                            return count.intValue();
20067                    }
20068                    catch (Exception e) {
20069                            throw processException(e);
20070                    }
20071                    finally {
20072                            closeSession(session);
20073                    }
20074            }
20075    
20076            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
20077            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
20078            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
20079            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20080                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20081                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
20082                            new String[] {
20083                                    Long.class.getName(), Long.class.getName(),
20084                                    String.class.getName()
20085                            },
20086                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20087                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20088                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
20089            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20090                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
20092                            new String[] {
20093                                    Long.class.getName(), Long.class.getName(),
20094                                    String.class.getName()
20095                            });
20096    
20097            /**
20098             * 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.
20099             *
20100             * @param groupId the group ID
20101             * @param classNameId the class name ID
20102             * @param structureId the structure ID
20103             * @return the matching journal article
20104             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20105             * @throws SystemException if a system exception occurred
20106             */
20107            @Override
20108            public JournalArticle findByG_C_S(long groupId, long classNameId,
20109                    String structureId) throws NoSuchArticleException, SystemException {
20110                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
20111                                    structureId);
20112    
20113                    if (journalArticle == null) {
20114                            StringBundler msg = new StringBundler(8);
20115    
20116                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20117    
20118                            msg.append("groupId=");
20119                            msg.append(groupId);
20120    
20121                            msg.append(", classNameId=");
20122                            msg.append(classNameId);
20123    
20124                            msg.append(", structureId=");
20125                            msg.append(structureId);
20126    
20127                            msg.append(StringPool.CLOSE_CURLY_BRACE);
20128    
20129                            if (_log.isWarnEnabled()) {
20130                                    _log.warn(msg.toString());
20131                            }
20132    
20133                            throw new NoSuchArticleException(msg.toString());
20134                    }
20135    
20136                    return journalArticle;
20137            }
20138    
20139            /**
20140             * 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.
20141             *
20142             * @param groupId the group ID
20143             * @param classNameId the class name ID
20144             * @param structureId the structure ID
20145             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
20146             * @throws SystemException if a system exception occurred
20147             */
20148            @Override
20149            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
20150                    String structureId) throws SystemException {
20151                    return fetchByG_C_S(groupId, classNameId, structureId, true);
20152            }
20153    
20154            /**
20155             * 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.
20156             *
20157             * @param groupId the group ID
20158             * @param classNameId the class name ID
20159             * @param structureId the structure ID
20160             * @param retrieveFromCache whether to use the finder cache
20161             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
20162             * @throws SystemException if a system exception occurred
20163             */
20164            @Override
20165            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
20166                    String structureId, boolean retrieveFromCache)
20167                    throws SystemException {
20168                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
20169    
20170                    Object result = null;
20171    
20172                    if (retrieveFromCache) {
20173                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
20174                                            finderArgs, this);
20175                    }
20176    
20177                    if (result instanceof JournalArticle) {
20178                            JournalArticle journalArticle = (JournalArticle)result;
20179    
20180                            if ((groupId != journalArticle.getGroupId()) ||
20181                                            (classNameId != journalArticle.getClassNameId()) ||
20182                                            !Validator.equals(structureId,
20183                                                    journalArticle.getStructureId())) {
20184                                    result = null;
20185                            }
20186                    }
20187    
20188                    if (result == null) {
20189                            StringBundler query = new StringBundler(5);
20190    
20191                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20192    
20193                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
20194    
20195                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
20196    
20197                            boolean bindStructureId = false;
20198    
20199                            if (structureId == null) {
20200                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
20201                            }
20202                            else if (structureId.equals(StringPool.BLANK)) {
20203                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
20204                            }
20205                            else {
20206                                    bindStructureId = true;
20207    
20208                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
20209                            }
20210    
20211                            String sql = query.toString();
20212    
20213                            Session session = null;
20214    
20215                            try {
20216                                    session = openSession();
20217    
20218                                    Query q = session.createQuery(sql);
20219    
20220                                    QueryPos qPos = QueryPos.getInstance(q);
20221    
20222                                    qPos.add(groupId);
20223    
20224                                    qPos.add(classNameId);
20225    
20226                                    if (bindStructureId) {
20227                                            qPos.add(structureId);
20228                                    }
20229    
20230                                    List<JournalArticle> list = q.list();
20231    
20232                                    if (list.isEmpty()) {
20233                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
20234                                                    finderArgs, list);
20235                                    }
20236                                    else {
20237                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
20238                                                    _log.warn(
20239                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
20240                                                            StringUtil.merge(finderArgs) +
20241                                                            ") 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.");
20242                                            }
20243    
20244                                            JournalArticle journalArticle = list.get(0);
20245    
20246                                            result = journalArticle;
20247    
20248                                            cacheResult(journalArticle);
20249    
20250                                            if ((journalArticle.getGroupId() != groupId) ||
20251                                                            (journalArticle.getClassNameId() != classNameId) ||
20252                                                            (journalArticle.getStructureId() == null) ||
20253                                                            !journalArticle.getStructureId().equals(structureId)) {
20254                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
20255                                                            finderArgs, journalArticle);
20256                                            }
20257                                    }
20258                            }
20259                            catch (Exception e) {
20260                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
20261                                            finderArgs);
20262    
20263                                    throw processException(e);
20264                            }
20265                            finally {
20266                                    closeSession(session);
20267                            }
20268                    }
20269    
20270                    if (result instanceof List<?>) {
20271                            return null;
20272                    }
20273                    else {
20274                            return (JournalArticle)result;
20275                    }
20276            }
20277    
20278            /**
20279             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
20280             *
20281             * @param groupId the group ID
20282             * @param classNameId the class name ID
20283             * @param structureId the structure ID
20284             * @return the journal article that was removed
20285             * @throws SystemException if a system exception occurred
20286             */
20287            @Override
20288            public JournalArticle removeByG_C_S(long groupId, long classNameId,
20289                    String structureId) throws NoSuchArticleException, SystemException {
20290                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
20291                                    structureId);
20292    
20293                    return remove(journalArticle);
20294            }
20295    
20296            /**
20297             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
20298             *
20299             * @param groupId the group ID
20300             * @param classNameId the class name ID
20301             * @param structureId the structure ID
20302             * @return the number of matching journal articles
20303             * @throws SystemException if a system exception occurred
20304             */
20305            @Override
20306            public int countByG_C_S(long groupId, long classNameId, String structureId)
20307                    throws SystemException {
20308                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
20309    
20310                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
20311    
20312                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20313                                    this);
20314    
20315                    if (count == null) {
20316                            StringBundler query = new StringBundler(4);
20317    
20318                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20319    
20320                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
20321    
20322                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
20323    
20324                            boolean bindStructureId = false;
20325    
20326                            if (structureId == null) {
20327                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
20328                            }
20329                            else if (structureId.equals(StringPool.BLANK)) {
20330                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
20331                            }
20332                            else {
20333                                    bindStructureId = true;
20334    
20335                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
20336                            }
20337    
20338                            String sql = query.toString();
20339    
20340                            Session session = null;
20341    
20342                            try {
20343                                    session = openSession();
20344    
20345                                    Query q = session.createQuery(sql);
20346    
20347                                    QueryPos qPos = QueryPos.getInstance(q);
20348    
20349                                    qPos.add(groupId);
20350    
20351                                    qPos.add(classNameId);
20352    
20353                                    if (bindStructureId) {
20354                                            qPos.add(structureId);
20355                                    }
20356    
20357                                    count = (Long)q.uniqueResult();
20358    
20359                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20360                            }
20361                            catch (Exception e) {
20362                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20363    
20364                                    throw processException(e);
20365                            }
20366                            finally {
20367                                    closeSession(session);
20368                            }
20369                    }
20370    
20371                    return count.intValue();
20372            }
20373    
20374            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
20375            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
20376            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
20377            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
20378            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
20379            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20380                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20381                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20382                            "findByG_C_T",
20383                            new String[] {
20384                                    Long.class.getName(), Long.class.getName(),
20385                                    String.class.getName(),
20386                                    
20387                            Integer.class.getName(), Integer.class.getName(),
20388                                    OrderByComparator.class.getName()
20389                            });
20390            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20391                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20392                            JournalArticleImpl.class,
20393                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
20394                            new String[] {
20395                                    Long.class.getName(), Long.class.getName(),
20396                                    String.class.getName()
20397                            },
20398                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20399                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20400                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
20401                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20402                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20403            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20404                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20405                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
20406                            new String[] {
20407                                    Long.class.getName(), Long.class.getName(),
20408                                    String.class.getName()
20409                            });
20410    
20411            /**
20412             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20413             *
20414             * @param groupId the group ID
20415             * @param classNameId the class name ID
20416             * @param templateId the template ID
20417             * @return the matching journal articles
20418             * @throws SystemException if a system exception occurred
20419             */
20420            @Override
20421            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
20422                    String templateId) throws SystemException {
20423                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
20424                            QueryUtil.ALL_POS, null);
20425            }
20426    
20427            /**
20428             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20429             *
20430             * <p>
20431             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20432             * </p>
20433             *
20434             * @param groupId the group ID
20435             * @param classNameId the class name ID
20436             * @param templateId the template ID
20437             * @param start the lower bound of the range of journal articles
20438             * @param end the upper bound of the range of journal articles (not inclusive)
20439             * @return the range of matching journal articles
20440             * @throws SystemException if a system exception occurred
20441             */
20442            @Override
20443            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
20444                    String templateId, int start, int end) throws SystemException {
20445                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
20446            }
20447    
20448            /**
20449             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20450             *
20451             * <p>
20452             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20453             * </p>
20454             *
20455             * @param groupId the group ID
20456             * @param classNameId the class name ID
20457             * @param templateId the template ID
20458             * @param start the lower bound of the range of journal articles
20459             * @param end the upper bound of the range of journal articles (not inclusive)
20460             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20461             * @return the ordered range of matching journal articles
20462             * @throws SystemException if a system exception occurred
20463             */
20464            @Override
20465            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
20466                    String templateId, int start, int end,
20467                    OrderByComparator orderByComparator) throws SystemException {
20468                    boolean pagination = true;
20469                    FinderPath finderPath = null;
20470                    Object[] finderArgs = null;
20471    
20472                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20473                                    (orderByComparator == null)) {
20474                            pagination = false;
20475                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
20476                            finderArgs = new Object[] { groupId, classNameId, templateId };
20477                    }
20478                    else {
20479                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
20480                            finderArgs = new Object[] {
20481                                            groupId, classNameId, templateId,
20482                                            
20483                                            start, end, orderByComparator
20484                                    };
20485                    }
20486    
20487                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20488                                    finderArgs, this);
20489    
20490                    if ((list != null) && !list.isEmpty()) {
20491                            for (JournalArticle journalArticle : list) {
20492                                    if ((groupId != journalArticle.getGroupId()) ||
20493                                                    (classNameId != journalArticle.getClassNameId()) ||
20494                                                    !Validator.equals(templateId,
20495                                                            journalArticle.getTemplateId())) {
20496                                            list = null;
20497    
20498                                            break;
20499                                    }
20500                            }
20501                    }
20502    
20503                    if (list == null) {
20504                            StringBundler query = null;
20505    
20506                            if (orderByComparator != null) {
20507                                    query = new StringBundler(5 +
20508                                                    (orderByComparator.getOrderByFields().length * 3));
20509                            }
20510                            else {
20511                                    query = new StringBundler(5);
20512                            }
20513    
20514                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20515    
20516                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20517    
20518                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20519    
20520                            boolean bindTemplateId = false;
20521    
20522                            if (templateId == null) {
20523                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20524                            }
20525                            else if (templateId.equals(StringPool.BLANK)) {
20526                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20527                            }
20528                            else {
20529                                    bindTemplateId = true;
20530    
20531                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20532                            }
20533    
20534                            if (orderByComparator != null) {
20535                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20536                                            orderByComparator);
20537                            }
20538                            else
20539                             if (pagination) {
20540                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20541                            }
20542    
20543                            String sql = query.toString();
20544    
20545                            Session session = null;
20546    
20547                            try {
20548                                    session = openSession();
20549    
20550                                    Query q = session.createQuery(sql);
20551    
20552                                    QueryPos qPos = QueryPos.getInstance(q);
20553    
20554                                    qPos.add(groupId);
20555    
20556                                    qPos.add(classNameId);
20557    
20558                                    if (bindTemplateId) {
20559                                            qPos.add(templateId);
20560                                    }
20561    
20562                                    if (!pagination) {
20563                                            list = (List<JournalArticle>)QueryUtil.list(q,
20564                                                            getDialect(), start, end, false);
20565    
20566                                            Collections.sort(list);
20567    
20568                                            list = new UnmodifiableList<JournalArticle>(list);
20569                                    }
20570                                    else {
20571                                            list = (List<JournalArticle>)QueryUtil.list(q,
20572                                                            getDialect(), start, end);
20573                                    }
20574    
20575                                    cacheResult(list);
20576    
20577                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20578                            }
20579                            catch (Exception e) {
20580                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20581    
20582                                    throw processException(e);
20583                            }
20584                            finally {
20585                                    closeSession(session);
20586                            }
20587                    }
20588    
20589                    return list;
20590            }
20591    
20592            /**
20593             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20594             *
20595             * @param groupId the group ID
20596             * @param classNameId the class name ID
20597             * @param templateId the template ID
20598             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20599             * @return the first matching journal article
20600             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20601             * @throws SystemException if a system exception occurred
20602             */
20603            @Override
20604            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
20605                    String templateId, OrderByComparator orderByComparator)
20606                    throws NoSuchArticleException, SystemException {
20607                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
20608                                    classNameId, templateId, orderByComparator);
20609    
20610                    if (journalArticle != null) {
20611                            return journalArticle;
20612                    }
20613    
20614                    StringBundler msg = new StringBundler(8);
20615    
20616                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20617    
20618                    msg.append("groupId=");
20619                    msg.append(groupId);
20620    
20621                    msg.append(", classNameId=");
20622                    msg.append(classNameId);
20623    
20624                    msg.append(", templateId=");
20625                    msg.append(templateId);
20626    
20627                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20628    
20629                    throw new NoSuchArticleException(msg.toString());
20630            }
20631    
20632            /**
20633             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20634             *
20635             * @param groupId the group ID
20636             * @param classNameId the class name ID
20637             * @param templateId the template ID
20638             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20639             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
20640             * @throws SystemException if a system exception occurred
20641             */
20642            @Override
20643            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
20644                    String templateId, OrderByComparator orderByComparator)
20645                    throws SystemException {
20646                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
20647                                    templateId, 0, 1, orderByComparator);
20648    
20649                    if (!list.isEmpty()) {
20650                            return list.get(0);
20651                    }
20652    
20653                    return null;
20654            }
20655    
20656            /**
20657             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20658             *
20659             * @param groupId the group ID
20660             * @param classNameId the class name ID
20661             * @param templateId the template ID
20662             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20663             * @return the last matching journal article
20664             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20665             * @throws SystemException if a system exception occurred
20666             */
20667            @Override
20668            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
20669                    String templateId, OrderByComparator orderByComparator)
20670                    throws NoSuchArticleException, SystemException {
20671                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
20672                                    templateId, orderByComparator);
20673    
20674                    if (journalArticle != null) {
20675                            return journalArticle;
20676                    }
20677    
20678                    StringBundler msg = new StringBundler(8);
20679    
20680                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20681    
20682                    msg.append("groupId=");
20683                    msg.append(groupId);
20684    
20685                    msg.append(", classNameId=");
20686                    msg.append(classNameId);
20687    
20688                    msg.append(", templateId=");
20689                    msg.append(templateId);
20690    
20691                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20692    
20693                    throw new NoSuchArticleException(msg.toString());
20694            }
20695    
20696            /**
20697             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20698             *
20699             * @param groupId the group ID
20700             * @param classNameId the class name ID
20701             * @param templateId the template ID
20702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20703             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20704             * @throws SystemException if a system exception occurred
20705             */
20706            @Override
20707            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
20708                    String templateId, OrderByComparator orderByComparator)
20709                    throws SystemException {
20710                    int count = countByG_C_T(groupId, classNameId, templateId);
20711    
20712                    if (count == 0) {
20713                            return null;
20714                    }
20715    
20716                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
20717                                    templateId, count - 1, count, orderByComparator);
20718    
20719                    if (!list.isEmpty()) {
20720                            return list.get(0);
20721                    }
20722    
20723                    return null;
20724            }
20725    
20726            /**
20727             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20728             *
20729             * @param id the primary key of the current journal article
20730             * @param groupId the group ID
20731             * @param classNameId the class name ID
20732             * @param templateId the template ID
20733             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20734             * @return the previous, current, and next journal article
20735             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20736             * @throws SystemException if a system exception occurred
20737             */
20738            @Override
20739            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
20740                    long classNameId, String templateId, OrderByComparator orderByComparator)
20741                    throws NoSuchArticleException, SystemException {
20742                    JournalArticle journalArticle = findByPrimaryKey(id);
20743    
20744                    Session session = null;
20745    
20746                    try {
20747                            session = openSession();
20748    
20749                            JournalArticle[] array = new JournalArticleImpl[3];
20750    
20751                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
20752                                            classNameId, templateId, orderByComparator, true);
20753    
20754                            array[1] = journalArticle;
20755    
20756                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
20757                                            classNameId, templateId, orderByComparator, false);
20758    
20759                            return array;
20760                    }
20761                    catch (Exception e) {
20762                            throw processException(e);
20763                    }
20764                    finally {
20765                            closeSession(session);
20766                    }
20767            }
20768    
20769            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
20770                    JournalArticle journalArticle, long groupId, long classNameId,
20771                    String templateId, OrderByComparator orderByComparator, boolean previous) {
20772                    StringBundler query = null;
20773    
20774                    if (orderByComparator != null) {
20775                            query = new StringBundler(6 +
20776                                            (orderByComparator.getOrderByFields().length * 6));
20777                    }
20778                    else {
20779                            query = new StringBundler(3);
20780                    }
20781    
20782                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20783    
20784                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20785    
20786                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20787    
20788                    boolean bindTemplateId = false;
20789    
20790                    if (templateId == null) {
20791                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20792                    }
20793                    else if (templateId.equals(StringPool.BLANK)) {
20794                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20795                    }
20796                    else {
20797                            bindTemplateId = true;
20798    
20799                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20800                    }
20801    
20802                    if (orderByComparator != null) {
20803                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20804    
20805                            if (orderByConditionFields.length > 0) {
20806                                    query.append(WHERE_AND);
20807                            }
20808    
20809                            for (int i = 0; i < orderByConditionFields.length; i++) {
20810                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20811                                    query.append(orderByConditionFields[i]);
20812    
20813                                    if ((i + 1) < orderByConditionFields.length) {
20814                                            if (orderByComparator.isAscending() ^ previous) {
20815                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20816                                            }
20817                                            else {
20818                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20819                                            }
20820                                    }
20821                                    else {
20822                                            if (orderByComparator.isAscending() ^ previous) {
20823                                                    query.append(WHERE_GREATER_THAN);
20824                                            }
20825                                            else {
20826                                                    query.append(WHERE_LESSER_THAN);
20827                                            }
20828                                    }
20829                            }
20830    
20831                            query.append(ORDER_BY_CLAUSE);
20832    
20833                            String[] orderByFields = orderByComparator.getOrderByFields();
20834    
20835                            for (int i = 0; i < orderByFields.length; i++) {
20836                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20837                                    query.append(orderByFields[i]);
20838    
20839                                    if ((i + 1) < orderByFields.length) {
20840                                            if (orderByComparator.isAscending() ^ previous) {
20841                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20842                                            }
20843                                            else {
20844                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20845                                            }
20846                                    }
20847                                    else {
20848                                            if (orderByComparator.isAscending() ^ previous) {
20849                                                    query.append(ORDER_BY_ASC);
20850                                            }
20851                                            else {
20852                                                    query.append(ORDER_BY_DESC);
20853                                            }
20854                                    }
20855                            }
20856                    }
20857                    else {
20858                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20859                    }
20860    
20861                    String sql = query.toString();
20862    
20863                    Query q = session.createQuery(sql);
20864    
20865                    q.setFirstResult(0);
20866                    q.setMaxResults(2);
20867    
20868                    QueryPos qPos = QueryPos.getInstance(q);
20869    
20870                    qPos.add(groupId);
20871    
20872                    qPos.add(classNameId);
20873    
20874                    if (bindTemplateId) {
20875                            qPos.add(templateId);
20876                    }
20877    
20878                    if (orderByComparator != null) {
20879                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20880    
20881                            for (Object value : values) {
20882                                    qPos.add(value);
20883                            }
20884                    }
20885    
20886                    List<JournalArticle> list = q.list();
20887    
20888                    if (list.size() == 2) {
20889                            return list.get(1);
20890                    }
20891                    else {
20892                            return null;
20893                    }
20894            }
20895    
20896            /**
20897             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20898             *
20899             * @param groupId the group ID
20900             * @param classNameId the class name ID
20901             * @param templateId the template ID
20902             * @return the matching journal articles that the user has permission to view
20903             * @throws SystemException if a system exception occurred
20904             */
20905            @Override
20906            public List<JournalArticle> filterFindByG_C_T(long groupId,
20907                    long classNameId, String templateId) throws SystemException {
20908                    return filterFindByG_C_T(groupId, classNameId, templateId,
20909                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20910            }
20911    
20912            /**
20913             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20914             *
20915             * <p>
20916             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20917             * </p>
20918             *
20919             * @param groupId the group ID
20920             * @param classNameId the class name ID
20921             * @param templateId the template ID
20922             * @param start the lower bound of the range of journal articles
20923             * @param end the upper bound of the range of journal articles (not inclusive)
20924             * @return the range of matching journal articles that the user has permission to view
20925             * @throws SystemException if a system exception occurred
20926             */
20927            @Override
20928            public List<JournalArticle> filterFindByG_C_T(long groupId,
20929                    long classNameId, String templateId, int start, int end)
20930                    throws SystemException {
20931                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
20932                            null);
20933            }
20934    
20935            /**
20936             * 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;.
20937             *
20938             * <p>
20939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20940             * </p>
20941             *
20942             * @param groupId the group ID
20943             * @param classNameId the class name ID
20944             * @param templateId the template ID
20945             * @param start the lower bound of the range of journal articles
20946             * @param end the upper bound of the range of journal articles (not inclusive)
20947             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20948             * @return the ordered range of matching journal articles that the user has permission to view
20949             * @throws SystemException if a system exception occurred
20950             */
20951            @Override
20952            public List<JournalArticle> filterFindByG_C_T(long groupId,
20953                    long classNameId, String templateId, int start, int end,
20954                    OrderByComparator orderByComparator) throws SystemException {
20955                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20956                            return findByG_C_T(groupId, classNameId, templateId, start, end,
20957                                    orderByComparator);
20958                    }
20959    
20960                    StringBundler query = null;
20961    
20962                    if (orderByComparator != null) {
20963                            query = new StringBundler(5 +
20964                                            (orderByComparator.getOrderByFields().length * 3));
20965                    }
20966                    else {
20967                            query = new StringBundler(5);
20968                    }
20969    
20970                    if (getDB().isSupportsInlineDistinct()) {
20971                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20972                    }
20973                    else {
20974                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20975                    }
20976    
20977                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20978    
20979                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20980    
20981                    boolean bindTemplateId = false;
20982    
20983                    if (templateId == null) {
20984                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20985                    }
20986                    else if (templateId.equals(StringPool.BLANK)) {
20987                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20988                    }
20989                    else {
20990                            bindTemplateId = true;
20991    
20992                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20993                    }
20994    
20995                    if (!getDB().isSupportsInlineDistinct()) {
20996                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20997                    }
20998    
20999                    if (orderByComparator != null) {
21000                            if (getDB().isSupportsInlineDistinct()) {
21001                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21002                                            orderByComparator, true);
21003                            }
21004                            else {
21005                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21006                                            orderByComparator, true);
21007                            }
21008                    }
21009                    else {
21010                            if (getDB().isSupportsInlineDistinct()) {
21011                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21012                            }
21013                            else {
21014                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21015                            }
21016                    }
21017    
21018                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21019                                    JournalArticle.class.getName(),
21020                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21021    
21022                    Session session = null;
21023    
21024                    try {
21025                            session = openSession();
21026    
21027                            SQLQuery q = session.createSQLQuery(sql);
21028    
21029                            if (getDB().isSupportsInlineDistinct()) {
21030                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21031                            }
21032                            else {
21033                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21034                            }
21035    
21036                            QueryPos qPos = QueryPos.getInstance(q);
21037    
21038                            qPos.add(groupId);
21039    
21040                            qPos.add(classNameId);
21041    
21042                            if (bindTemplateId) {
21043                                    qPos.add(templateId);
21044                            }
21045    
21046                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21047                                    end);
21048                    }
21049                    catch (Exception e) {
21050                            throw processException(e);
21051                    }
21052                    finally {
21053                            closeSession(session);
21054                    }
21055            }
21056    
21057            /**
21058             * 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;.
21059             *
21060             * @param id the primary key of the current journal article
21061             * @param groupId the group ID
21062             * @param classNameId the class name ID
21063             * @param templateId the template ID
21064             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21065             * @return the previous, current, and next journal article
21066             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21067             * @throws SystemException if a system exception occurred
21068             */
21069            @Override
21070            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
21071                    long groupId, long classNameId, String templateId,
21072                    OrderByComparator orderByComparator)
21073                    throws NoSuchArticleException, SystemException {
21074                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21075                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
21076                                    templateId, orderByComparator);
21077                    }
21078    
21079                    JournalArticle journalArticle = findByPrimaryKey(id);
21080    
21081                    Session session = null;
21082    
21083                    try {
21084                            session = openSession();
21085    
21086                            JournalArticle[] array = new JournalArticleImpl[3];
21087    
21088                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
21089                                            groupId, classNameId, templateId, orderByComparator, true);
21090    
21091                            array[1] = journalArticle;
21092    
21093                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
21094                                            groupId, classNameId, templateId, orderByComparator, false);
21095    
21096                            return array;
21097                    }
21098                    catch (Exception e) {
21099                            throw processException(e);
21100                    }
21101                    finally {
21102                            closeSession(session);
21103                    }
21104            }
21105    
21106            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
21107                    JournalArticle journalArticle, long groupId, long classNameId,
21108                    String templateId, OrderByComparator orderByComparator, boolean previous) {
21109                    StringBundler query = null;
21110    
21111                    if (orderByComparator != null) {
21112                            query = new StringBundler(6 +
21113                                            (orderByComparator.getOrderByFields().length * 6));
21114                    }
21115                    else {
21116                            query = new StringBundler(3);
21117                    }
21118    
21119                    if (getDB().isSupportsInlineDistinct()) {
21120                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21121                    }
21122                    else {
21123                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21124                    }
21125    
21126                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
21127    
21128                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
21129    
21130                    boolean bindTemplateId = false;
21131    
21132                    if (templateId == null) {
21133                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
21134                    }
21135                    else if (templateId.equals(StringPool.BLANK)) {
21136                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
21137                    }
21138                    else {
21139                            bindTemplateId = true;
21140    
21141                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
21142                    }
21143    
21144                    if (!getDB().isSupportsInlineDistinct()) {
21145                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21146                    }
21147    
21148                    if (orderByComparator != null) {
21149                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21150    
21151                            if (orderByConditionFields.length > 0) {
21152                                    query.append(WHERE_AND);
21153                            }
21154    
21155                            for (int i = 0; i < orderByConditionFields.length; i++) {
21156                                    if (getDB().isSupportsInlineDistinct()) {
21157                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21158                                    }
21159                                    else {
21160                                            query.append(_ORDER_BY_ENTITY_TABLE);
21161                                    }
21162    
21163                                    query.append(orderByConditionFields[i]);
21164    
21165                                    if ((i + 1) < orderByConditionFields.length) {
21166                                            if (orderByComparator.isAscending() ^ previous) {
21167                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21168                                            }
21169                                            else {
21170                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21171                                            }
21172                                    }
21173                                    else {
21174                                            if (orderByComparator.isAscending() ^ previous) {
21175                                                    query.append(WHERE_GREATER_THAN);
21176                                            }
21177                                            else {
21178                                                    query.append(WHERE_LESSER_THAN);
21179                                            }
21180                                    }
21181                            }
21182    
21183                            query.append(ORDER_BY_CLAUSE);
21184    
21185                            String[] orderByFields = orderByComparator.getOrderByFields();
21186    
21187                            for (int i = 0; i < orderByFields.length; i++) {
21188                                    if (getDB().isSupportsInlineDistinct()) {
21189                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21190                                    }
21191                                    else {
21192                                            query.append(_ORDER_BY_ENTITY_TABLE);
21193                                    }
21194    
21195                                    query.append(orderByFields[i]);
21196    
21197                                    if ((i + 1) < orderByFields.length) {
21198                                            if (orderByComparator.isAscending() ^ previous) {
21199                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21200                                            }
21201                                            else {
21202                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21203                                            }
21204                                    }
21205                                    else {
21206                                            if (orderByComparator.isAscending() ^ previous) {
21207                                                    query.append(ORDER_BY_ASC);
21208                                            }
21209                                            else {
21210                                                    query.append(ORDER_BY_DESC);
21211                                            }
21212                                    }
21213                            }
21214                    }
21215                    else {
21216                            if (getDB().isSupportsInlineDistinct()) {
21217                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21218                            }
21219                            else {
21220                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21221                            }
21222                    }
21223    
21224                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21225                                    JournalArticle.class.getName(),
21226                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21227    
21228                    SQLQuery q = session.createSQLQuery(sql);
21229    
21230                    q.setFirstResult(0);
21231                    q.setMaxResults(2);
21232    
21233                    if (getDB().isSupportsInlineDistinct()) {
21234                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21235                    }
21236                    else {
21237                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21238                    }
21239    
21240                    QueryPos qPos = QueryPos.getInstance(q);
21241    
21242                    qPos.add(groupId);
21243    
21244                    qPos.add(classNameId);
21245    
21246                    if (bindTemplateId) {
21247                            qPos.add(templateId);
21248                    }
21249    
21250                    if (orderByComparator != null) {
21251                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21252    
21253                            for (Object value : values) {
21254                                    qPos.add(value);
21255                            }
21256                    }
21257    
21258                    List<JournalArticle> list = q.list();
21259    
21260                    if (list.size() == 2) {
21261                            return list.get(1);
21262                    }
21263                    else {
21264                            return null;
21265                    }
21266            }
21267    
21268            /**
21269             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
21270             *
21271             * @param groupId the group ID
21272             * @param classNameId the class name ID
21273             * @param templateId the template ID
21274             * @throws SystemException if a system exception occurred
21275             */
21276            @Override
21277            public void removeByG_C_T(long groupId, long classNameId, String templateId)
21278                    throws SystemException {
21279                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
21280                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21281                            remove(journalArticle);
21282                    }
21283            }
21284    
21285            /**
21286             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
21287             *
21288             * @param groupId the group ID
21289             * @param classNameId the class name ID
21290             * @param templateId the template ID
21291             * @return the number of matching journal articles
21292             * @throws SystemException if a system exception occurred
21293             */
21294            @Override
21295            public int countByG_C_T(long groupId, long classNameId, String templateId)
21296                    throws SystemException {
21297                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
21298    
21299                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
21300    
21301                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21302                                    this);
21303    
21304                    if (count == null) {
21305                            StringBundler query = new StringBundler(4);
21306    
21307                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21308    
21309                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
21310    
21311                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
21312    
21313                            boolean bindTemplateId = false;
21314    
21315                            if (templateId == null) {
21316                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
21317                            }
21318                            else if (templateId.equals(StringPool.BLANK)) {
21319                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
21320                            }
21321                            else {
21322                                    bindTemplateId = true;
21323    
21324                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
21325                            }
21326    
21327                            String sql = query.toString();
21328    
21329                            Session session = null;
21330    
21331                            try {
21332                                    session = openSession();
21333    
21334                                    Query q = session.createQuery(sql);
21335    
21336                                    QueryPos qPos = QueryPos.getInstance(q);
21337    
21338                                    qPos.add(groupId);
21339    
21340                                    qPos.add(classNameId);
21341    
21342                                    if (bindTemplateId) {
21343                                            qPos.add(templateId);
21344                                    }
21345    
21346                                    count = (Long)q.uniqueResult();
21347    
21348                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21349                            }
21350                            catch (Exception e) {
21351                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21352    
21353                                    throw processException(e);
21354                            }
21355                            finally {
21356                                    closeSession(session);
21357                            }
21358                    }
21359    
21360                    return count.intValue();
21361            }
21362    
21363            /**
21364             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
21365             *
21366             * @param groupId the group ID
21367             * @param classNameId the class name ID
21368             * @param templateId the template ID
21369             * @return the number of matching journal articles that the user has permission to view
21370             * @throws SystemException if a system exception occurred
21371             */
21372            @Override
21373            public int filterCountByG_C_T(long groupId, long classNameId,
21374                    String templateId) throws SystemException {
21375                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21376                            return countByG_C_T(groupId, classNameId, templateId);
21377                    }
21378    
21379                    StringBundler query = new StringBundler(4);
21380    
21381                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21382    
21383                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
21384    
21385                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
21386    
21387                    boolean bindTemplateId = false;
21388    
21389                    if (templateId == null) {
21390                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
21391                    }
21392                    else if (templateId.equals(StringPool.BLANK)) {
21393                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
21394                    }
21395                    else {
21396                            bindTemplateId = true;
21397    
21398                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
21399                    }
21400    
21401                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21402                                    JournalArticle.class.getName(),
21403                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21404    
21405                    Session session = null;
21406    
21407                    try {
21408                            session = openSession();
21409    
21410                            SQLQuery q = session.createSQLQuery(sql);
21411    
21412                            q.addScalar(COUNT_COLUMN_NAME,
21413                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21414    
21415                            QueryPos qPos = QueryPos.getInstance(q);
21416    
21417                            qPos.add(groupId);
21418    
21419                            qPos.add(classNameId);
21420    
21421                            if (bindTemplateId) {
21422                                    qPos.add(templateId);
21423                            }
21424    
21425                            Long count = (Long)q.uniqueResult();
21426    
21427                            return count.intValue();
21428                    }
21429                    catch (Exception e) {
21430                            throw processException(e);
21431                    }
21432                    finally {
21433                            closeSession(session);
21434                    }
21435            }
21436    
21437            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
21438            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
21439            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
21440            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
21441            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
21442            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21443                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21444                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
21445                            "findByG_C_L",
21446                            new String[] {
21447                                    Long.class.getName(), Long.class.getName(),
21448                                    String.class.getName(),
21449                                    
21450                            Integer.class.getName(), Integer.class.getName(),
21451                                    OrderByComparator.class.getName()
21452                            });
21453            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21454                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21455                            JournalArticleImpl.class,
21456                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
21457                            new String[] {
21458                                    Long.class.getName(), Long.class.getName(),
21459                                    String.class.getName()
21460                            },
21461                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21462                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
21463                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
21464                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21465                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21466            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21467                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21468                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
21469                            new String[] {
21470                                    Long.class.getName(), Long.class.getName(),
21471                                    String.class.getName()
21472                            });
21473    
21474            /**
21475             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21476             *
21477             * @param groupId the group ID
21478             * @param classNameId the class name ID
21479             * @param layoutUuid the layout uuid
21480             * @return the matching journal articles
21481             * @throws SystemException if a system exception occurred
21482             */
21483            @Override
21484            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
21485                    String layoutUuid) throws SystemException {
21486                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
21487                            QueryUtil.ALL_POS, null);
21488            }
21489    
21490            /**
21491             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21492             *
21493             * <p>
21494             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21495             * </p>
21496             *
21497             * @param groupId the group ID
21498             * @param classNameId the class name ID
21499             * @param layoutUuid the layout uuid
21500             * @param start the lower bound of the range of journal articles
21501             * @param end the upper bound of the range of journal articles (not inclusive)
21502             * @return the range of matching journal articles
21503             * @throws SystemException if a system exception occurred
21504             */
21505            @Override
21506            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
21507                    String layoutUuid, int start, int end) throws SystemException {
21508                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
21509            }
21510    
21511            /**
21512             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21513             *
21514             * <p>
21515             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21516             * </p>
21517             *
21518             * @param groupId the group ID
21519             * @param classNameId the class name ID
21520             * @param layoutUuid the layout uuid
21521             * @param start the lower bound of the range of journal articles
21522             * @param end the upper bound of the range of journal articles (not inclusive)
21523             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21524             * @return the ordered range of matching journal articles
21525             * @throws SystemException if a system exception occurred
21526             */
21527            @Override
21528            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
21529                    String layoutUuid, int start, int end,
21530                    OrderByComparator orderByComparator) throws SystemException {
21531                    boolean pagination = true;
21532                    FinderPath finderPath = null;
21533                    Object[] finderArgs = null;
21534    
21535                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21536                                    (orderByComparator == null)) {
21537                            pagination = false;
21538                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
21539                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
21540                    }
21541                    else {
21542                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
21543                            finderArgs = new Object[] {
21544                                            groupId, classNameId, layoutUuid,
21545                                            
21546                                            start, end, orderByComparator
21547                                    };
21548                    }
21549    
21550                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21551                                    finderArgs, this);
21552    
21553                    if ((list != null) && !list.isEmpty()) {
21554                            for (JournalArticle journalArticle : list) {
21555                                    if ((groupId != journalArticle.getGroupId()) ||
21556                                                    (classNameId != journalArticle.getClassNameId()) ||
21557                                                    !Validator.equals(layoutUuid,
21558                                                            journalArticle.getLayoutUuid())) {
21559                                            list = null;
21560    
21561                                            break;
21562                                    }
21563                            }
21564                    }
21565    
21566                    if (list == null) {
21567                            StringBundler query = null;
21568    
21569                            if (orderByComparator != null) {
21570                                    query = new StringBundler(5 +
21571                                                    (orderByComparator.getOrderByFields().length * 3));
21572                            }
21573                            else {
21574                                    query = new StringBundler(5);
21575                            }
21576    
21577                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21578    
21579                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21580    
21581                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21582    
21583                            boolean bindLayoutUuid = false;
21584    
21585                            if (layoutUuid == null) {
21586                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21587                            }
21588                            else if (layoutUuid.equals(StringPool.BLANK)) {
21589                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21590                            }
21591                            else {
21592                                    bindLayoutUuid = true;
21593    
21594                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21595                            }
21596    
21597                            if (orderByComparator != null) {
21598                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21599                                            orderByComparator);
21600                            }
21601                            else
21602                             if (pagination) {
21603                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21604                            }
21605    
21606                            String sql = query.toString();
21607    
21608                            Session session = null;
21609    
21610                            try {
21611                                    session = openSession();
21612    
21613                                    Query q = session.createQuery(sql);
21614    
21615                                    QueryPos qPos = QueryPos.getInstance(q);
21616    
21617                                    qPos.add(groupId);
21618    
21619                                    qPos.add(classNameId);
21620    
21621                                    if (bindLayoutUuid) {
21622                                            qPos.add(layoutUuid);
21623                                    }
21624    
21625                                    if (!pagination) {
21626                                            list = (List<JournalArticle>)QueryUtil.list(q,
21627                                                            getDialect(), start, end, false);
21628    
21629                                            Collections.sort(list);
21630    
21631                                            list = new UnmodifiableList<JournalArticle>(list);
21632                                    }
21633                                    else {
21634                                            list = (List<JournalArticle>)QueryUtil.list(q,
21635                                                            getDialect(), start, end);
21636                                    }
21637    
21638                                    cacheResult(list);
21639    
21640                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21641                            }
21642                            catch (Exception e) {
21643                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21644    
21645                                    throw processException(e);
21646                            }
21647                            finally {
21648                                    closeSession(session);
21649                            }
21650                    }
21651    
21652                    return list;
21653            }
21654    
21655            /**
21656             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21657             *
21658             * @param groupId the group ID
21659             * @param classNameId the class name ID
21660             * @param layoutUuid the layout uuid
21661             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21662             * @return the first matching journal article
21663             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21664             * @throws SystemException if a system exception occurred
21665             */
21666            @Override
21667            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
21668                    String layoutUuid, OrderByComparator orderByComparator)
21669                    throws NoSuchArticleException, SystemException {
21670                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
21671                                    classNameId, layoutUuid, orderByComparator);
21672    
21673                    if (journalArticle != null) {
21674                            return journalArticle;
21675                    }
21676    
21677                    StringBundler msg = new StringBundler(8);
21678    
21679                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21680    
21681                    msg.append("groupId=");
21682                    msg.append(groupId);
21683    
21684                    msg.append(", classNameId=");
21685                    msg.append(classNameId);
21686    
21687                    msg.append(", layoutUuid=");
21688                    msg.append(layoutUuid);
21689    
21690                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21691    
21692                    throw new NoSuchArticleException(msg.toString());
21693            }
21694    
21695            /**
21696             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21697             *
21698             * @param groupId the group ID
21699             * @param classNameId the class name ID
21700             * @param layoutUuid the layout uuid
21701             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21702             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21703             * @throws SystemException if a system exception occurred
21704             */
21705            @Override
21706            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
21707                    String layoutUuid, OrderByComparator orderByComparator)
21708                    throws SystemException {
21709                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
21710                                    layoutUuid, 0, 1, orderByComparator);
21711    
21712                    if (!list.isEmpty()) {
21713                            return list.get(0);
21714                    }
21715    
21716                    return null;
21717            }
21718    
21719            /**
21720             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21721             *
21722             * @param groupId the group ID
21723             * @param classNameId the class name ID
21724             * @param layoutUuid the layout uuid
21725             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21726             * @return the last matching journal article
21727             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21728             * @throws SystemException if a system exception occurred
21729             */
21730            @Override
21731            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
21732                    String layoutUuid, OrderByComparator orderByComparator)
21733                    throws NoSuchArticleException, SystemException {
21734                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
21735                                    layoutUuid, orderByComparator);
21736    
21737                    if (journalArticle != null) {
21738                            return journalArticle;
21739                    }
21740    
21741                    StringBundler msg = new StringBundler(8);
21742    
21743                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21744    
21745                    msg.append("groupId=");
21746                    msg.append(groupId);
21747    
21748                    msg.append(", classNameId=");
21749                    msg.append(classNameId);
21750    
21751                    msg.append(", layoutUuid=");
21752                    msg.append(layoutUuid);
21753    
21754                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21755    
21756                    throw new NoSuchArticleException(msg.toString());
21757            }
21758    
21759            /**
21760             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21761             *
21762             * @param groupId the group ID
21763             * @param classNameId the class name ID
21764             * @param layoutUuid the layout uuid
21765             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21766             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21767             * @throws SystemException if a system exception occurred
21768             */
21769            @Override
21770            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
21771                    String layoutUuid, OrderByComparator orderByComparator)
21772                    throws SystemException {
21773                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
21774    
21775                    if (count == 0) {
21776                            return null;
21777                    }
21778    
21779                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
21780                                    layoutUuid, count - 1, count, orderByComparator);
21781    
21782                    if (!list.isEmpty()) {
21783                            return list.get(0);
21784                    }
21785    
21786                    return null;
21787            }
21788    
21789            /**
21790             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21791             *
21792             * @param id the primary key of the current journal article
21793             * @param groupId the group ID
21794             * @param classNameId the class name ID
21795             * @param layoutUuid the layout uuid
21796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21797             * @return the previous, current, and next journal article
21798             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21799             * @throws SystemException if a system exception occurred
21800             */
21801            @Override
21802            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
21803                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
21804                    throws NoSuchArticleException, SystemException {
21805                    JournalArticle journalArticle = findByPrimaryKey(id);
21806    
21807                    Session session = null;
21808    
21809                    try {
21810                            session = openSession();
21811    
21812                            JournalArticle[] array = new JournalArticleImpl[3];
21813    
21814                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
21815                                            classNameId, layoutUuid, orderByComparator, true);
21816    
21817                            array[1] = journalArticle;
21818    
21819                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
21820                                            classNameId, layoutUuid, orderByComparator, false);
21821    
21822                            return array;
21823                    }
21824                    catch (Exception e) {
21825                            throw processException(e);
21826                    }
21827                    finally {
21828                            closeSession(session);
21829                    }
21830            }
21831    
21832            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
21833                    JournalArticle journalArticle, long groupId, long classNameId,
21834                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
21835                    StringBundler query = null;
21836    
21837                    if (orderByComparator != null) {
21838                            query = new StringBundler(6 +
21839                                            (orderByComparator.getOrderByFields().length * 6));
21840                    }
21841                    else {
21842                            query = new StringBundler(3);
21843                    }
21844    
21845                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21846    
21847                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21848    
21849                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21850    
21851                    boolean bindLayoutUuid = false;
21852    
21853                    if (layoutUuid == null) {
21854                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21855                    }
21856                    else if (layoutUuid.equals(StringPool.BLANK)) {
21857                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21858                    }
21859                    else {
21860                            bindLayoutUuid = true;
21861    
21862                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21863                    }
21864    
21865                    if (orderByComparator != null) {
21866                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21867    
21868                            if (orderByConditionFields.length > 0) {
21869                                    query.append(WHERE_AND);
21870                            }
21871    
21872                            for (int i = 0; i < orderByConditionFields.length; i++) {
21873                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21874                                    query.append(orderByConditionFields[i]);
21875    
21876                                    if ((i + 1) < orderByConditionFields.length) {
21877                                            if (orderByComparator.isAscending() ^ previous) {
21878                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21879                                            }
21880                                            else {
21881                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21882                                            }
21883                                    }
21884                                    else {
21885                                            if (orderByComparator.isAscending() ^ previous) {
21886                                                    query.append(WHERE_GREATER_THAN);
21887                                            }
21888                                            else {
21889                                                    query.append(WHERE_LESSER_THAN);
21890                                            }
21891                                    }
21892                            }
21893    
21894                            query.append(ORDER_BY_CLAUSE);
21895    
21896                            String[] orderByFields = orderByComparator.getOrderByFields();
21897    
21898                            for (int i = 0; i < orderByFields.length; i++) {
21899                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21900                                    query.append(orderByFields[i]);
21901    
21902                                    if ((i + 1) < orderByFields.length) {
21903                                            if (orderByComparator.isAscending() ^ previous) {
21904                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21905                                            }
21906                                            else {
21907                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21908                                            }
21909                                    }
21910                                    else {
21911                                            if (orderByComparator.isAscending() ^ previous) {
21912                                                    query.append(ORDER_BY_ASC);
21913                                            }
21914                                            else {
21915                                                    query.append(ORDER_BY_DESC);
21916                                            }
21917                                    }
21918                            }
21919                    }
21920                    else {
21921                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21922                    }
21923    
21924                    String sql = query.toString();
21925    
21926                    Query q = session.createQuery(sql);
21927    
21928                    q.setFirstResult(0);
21929                    q.setMaxResults(2);
21930    
21931                    QueryPos qPos = QueryPos.getInstance(q);
21932    
21933                    qPos.add(groupId);
21934    
21935                    qPos.add(classNameId);
21936    
21937                    if (bindLayoutUuid) {
21938                            qPos.add(layoutUuid);
21939                    }
21940    
21941                    if (orderByComparator != null) {
21942                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21943    
21944                            for (Object value : values) {
21945                                    qPos.add(value);
21946                            }
21947                    }
21948    
21949                    List<JournalArticle> list = q.list();
21950    
21951                    if (list.size() == 2) {
21952                            return list.get(1);
21953                    }
21954                    else {
21955                            return null;
21956                    }
21957            }
21958    
21959            /**
21960             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21961             *
21962             * @param groupId the group ID
21963             * @param classNameId the class name ID
21964             * @param layoutUuid the layout uuid
21965             * @return the matching journal articles that the user has permission to view
21966             * @throws SystemException if a system exception occurred
21967             */
21968            @Override
21969            public List<JournalArticle> filterFindByG_C_L(long groupId,
21970                    long classNameId, String layoutUuid) throws SystemException {
21971                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
21972                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21973            }
21974    
21975            /**
21976             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21977             *
21978             * <p>
21979             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21980             * </p>
21981             *
21982             * @param groupId the group ID
21983             * @param classNameId the class name ID
21984             * @param layoutUuid the layout uuid
21985             * @param start the lower bound of the range of journal articles
21986             * @param end the upper bound of the range of journal articles (not inclusive)
21987             * @return the range of matching journal articles that the user has permission to view
21988             * @throws SystemException if a system exception occurred
21989             */
21990            @Override
21991            public List<JournalArticle> filterFindByG_C_L(long groupId,
21992                    long classNameId, String layoutUuid, int start, int end)
21993                    throws SystemException {
21994                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
21995                            null);
21996            }
21997    
21998            /**
21999             * 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;.
22000             *
22001             * <p>
22002             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22003             * </p>
22004             *
22005             * @param groupId the group ID
22006             * @param classNameId the class name ID
22007             * @param layoutUuid the layout uuid
22008             * @param start the lower bound of the range of journal articles
22009             * @param end the upper bound of the range of journal articles (not inclusive)
22010             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22011             * @return the ordered range of matching journal articles that the user has permission to view
22012             * @throws SystemException if a system exception occurred
22013             */
22014            @Override
22015            public List<JournalArticle> filterFindByG_C_L(long groupId,
22016                    long classNameId, String layoutUuid, int start, int end,
22017                    OrderByComparator orderByComparator) throws SystemException {
22018                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22019                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
22020                                    orderByComparator);
22021                    }
22022    
22023                    StringBundler query = null;
22024    
22025                    if (orderByComparator != null) {
22026                            query = new StringBundler(5 +
22027                                            (orderByComparator.getOrderByFields().length * 3));
22028                    }
22029                    else {
22030                            query = new StringBundler(5);
22031                    }
22032    
22033                    if (getDB().isSupportsInlineDistinct()) {
22034                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22035                    }
22036                    else {
22037                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22038                    }
22039    
22040                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
22041    
22042                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
22043    
22044                    boolean bindLayoutUuid = false;
22045    
22046                    if (layoutUuid == null) {
22047                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
22048                    }
22049                    else if (layoutUuid.equals(StringPool.BLANK)) {
22050                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
22051                    }
22052                    else {
22053                            bindLayoutUuid = true;
22054    
22055                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
22056                    }
22057    
22058                    if (!getDB().isSupportsInlineDistinct()) {
22059                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22060                    }
22061    
22062                    if (orderByComparator != null) {
22063                            if (getDB().isSupportsInlineDistinct()) {
22064                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22065                                            orderByComparator, true);
22066                            }
22067                            else {
22068                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22069                                            orderByComparator, true);
22070                            }
22071                    }
22072                    else {
22073                            if (getDB().isSupportsInlineDistinct()) {
22074                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22075                            }
22076                            else {
22077                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22078                            }
22079                    }
22080    
22081                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22082                                    JournalArticle.class.getName(),
22083                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22084    
22085                    Session session = null;
22086    
22087                    try {
22088                            session = openSession();
22089    
22090                            SQLQuery q = session.createSQLQuery(sql);
22091    
22092                            if (getDB().isSupportsInlineDistinct()) {
22093                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22094                            }
22095                            else {
22096                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22097                            }
22098    
22099                            QueryPos qPos = QueryPos.getInstance(q);
22100    
22101                            qPos.add(groupId);
22102    
22103                            qPos.add(classNameId);
22104    
22105                            if (bindLayoutUuid) {
22106                                    qPos.add(layoutUuid);
22107                            }
22108    
22109                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22110                                    end);
22111                    }
22112                    catch (Exception e) {
22113                            throw processException(e);
22114                    }
22115                    finally {
22116                            closeSession(session);
22117                    }
22118            }
22119    
22120            /**
22121             * 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;.
22122             *
22123             * @param id the primary key of the current journal article
22124             * @param groupId the group ID
22125             * @param classNameId the class name ID
22126             * @param layoutUuid the layout uuid
22127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22128             * @return the previous, current, and next journal article
22129             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22130             * @throws SystemException if a system exception occurred
22131             */
22132            @Override
22133            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
22134                    long groupId, long classNameId, String layoutUuid,
22135                    OrderByComparator orderByComparator)
22136                    throws NoSuchArticleException, SystemException {
22137                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22138                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
22139                                    layoutUuid, orderByComparator);
22140                    }
22141    
22142                    JournalArticle journalArticle = findByPrimaryKey(id);
22143    
22144                    Session session = null;
22145    
22146                    try {
22147                            session = openSession();
22148    
22149                            JournalArticle[] array = new JournalArticleImpl[3];
22150    
22151                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
22152                                            groupId, classNameId, layoutUuid, orderByComparator, true);
22153    
22154                            array[1] = journalArticle;
22155    
22156                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
22157                                            groupId, classNameId, layoutUuid, orderByComparator, false);
22158    
22159                            return array;
22160                    }
22161                    catch (Exception e) {
22162                            throw processException(e);
22163                    }
22164                    finally {
22165                            closeSession(session);
22166                    }
22167            }
22168    
22169            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
22170                    JournalArticle journalArticle, long groupId, long classNameId,
22171                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
22172                    StringBundler query = null;
22173    
22174                    if (orderByComparator != null) {
22175                            query = new StringBundler(6 +
22176                                            (orderByComparator.getOrderByFields().length * 6));
22177                    }
22178                    else {
22179                            query = new StringBundler(3);
22180                    }
22181    
22182                    if (getDB().isSupportsInlineDistinct()) {
22183                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22184                    }
22185                    else {
22186                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22187                    }
22188    
22189                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
22190    
22191                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
22192    
22193                    boolean bindLayoutUuid = false;
22194    
22195                    if (layoutUuid == null) {
22196                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
22197                    }
22198                    else if (layoutUuid.equals(StringPool.BLANK)) {
22199                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
22200                    }
22201                    else {
22202                            bindLayoutUuid = true;
22203    
22204                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
22205                    }
22206    
22207                    if (!getDB().isSupportsInlineDistinct()) {
22208                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22209                    }
22210    
22211                    if (orderByComparator != null) {
22212                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22213    
22214                            if (orderByConditionFields.length > 0) {
22215                                    query.append(WHERE_AND);
22216                            }
22217    
22218                            for (int i = 0; i < orderByConditionFields.length; i++) {
22219                                    if (getDB().isSupportsInlineDistinct()) {
22220                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22221                                    }
22222                                    else {
22223                                            query.append(_ORDER_BY_ENTITY_TABLE);
22224                                    }
22225    
22226                                    query.append(orderByConditionFields[i]);
22227    
22228                                    if ((i + 1) < orderByConditionFields.length) {
22229                                            if (orderByComparator.isAscending() ^ previous) {
22230                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22231                                            }
22232                                            else {
22233                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22234                                            }
22235                                    }
22236                                    else {
22237                                            if (orderByComparator.isAscending() ^ previous) {
22238                                                    query.append(WHERE_GREATER_THAN);
22239                                            }
22240                                            else {
22241                                                    query.append(WHERE_LESSER_THAN);
22242                                            }
22243                                    }
22244                            }
22245    
22246                            query.append(ORDER_BY_CLAUSE);
22247    
22248                            String[] orderByFields = orderByComparator.getOrderByFields();
22249    
22250                            for (int i = 0; i < orderByFields.length; i++) {
22251                                    if (getDB().isSupportsInlineDistinct()) {
22252                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22253                                    }
22254                                    else {
22255                                            query.append(_ORDER_BY_ENTITY_TABLE);
22256                                    }
22257    
22258                                    query.append(orderByFields[i]);
22259    
22260                                    if ((i + 1) < orderByFields.length) {
22261                                            if (orderByComparator.isAscending() ^ previous) {
22262                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22263                                            }
22264                                            else {
22265                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22266                                            }
22267                                    }
22268                                    else {
22269                                            if (orderByComparator.isAscending() ^ previous) {
22270                                                    query.append(ORDER_BY_ASC);
22271                                            }
22272                                            else {
22273                                                    query.append(ORDER_BY_DESC);
22274                                            }
22275                                    }
22276                            }
22277                    }
22278                    else {
22279                            if (getDB().isSupportsInlineDistinct()) {
22280                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22281                            }
22282                            else {
22283                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22284                            }
22285                    }
22286    
22287                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22288                                    JournalArticle.class.getName(),
22289                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22290    
22291                    SQLQuery q = session.createSQLQuery(sql);
22292    
22293                    q.setFirstResult(0);
22294                    q.setMaxResults(2);
22295    
22296                    if (getDB().isSupportsInlineDistinct()) {
22297                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22298                    }
22299                    else {
22300                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22301                    }
22302    
22303                    QueryPos qPos = QueryPos.getInstance(q);
22304    
22305                    qPos.add(groupId);
22306    
22307                    qPos.add(classNameId);
22308    
22309                    if (bindLayoutUuid) {
22310                            qPos.add(layoutUuid);
22311                    }
22312    
22313                    if (orderByComparator != null) {
22314                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22315    
22316                            for (Object value : values) {
22317                                    qPos.add(value);
22318                            }
22319                    }
22320    
22321                    List<JournalArticle> list = q.list();
22322    
22323                    if (list.size() == 2) {
22324                            return list.get(1);
22325                    }
22326                    else {
22327                            return null;
22328                    }
22329            }
22330    
22331            /**
22332             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
22333             *
22334             * @param groupId the group ID
22335             * @param classNameId the class name ID
22336             * @param layoutUuid the layout uuid
22337             * @throws SystemException if a system exception occurred
22338             */
22339            @Override
22340            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
22341                    throws SystemException {
22342                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
22343                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22344                            remove(journalArticle);
22345                    }
22346            }
22347    
22348            /**
22349             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
22350             *
22351             * @param groupId the group ID
22352             * @param classNameId the class name ID
22353             * @param layoutUuid the layout uuid
22354             * @return the number of matching journal articles
22355             * @throws SystemException if a system exception occurred
22356             */
22357            @Override
22358            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
22359                    throws SystemException {
22360                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
22361    
22362                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
22363    
22364                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22365                                    this);
22366    
22367                    if (count == null) {
22368                            StringBundler query = new StringBundler(4);
22369    
22370                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22371    
22372                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
22373    
22374                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
22375    
22376                            boolean bindLayoutUuid = false;
22377    
22378                            if (layoutUuid == null) {
22379                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
22380                            }
22381                            else if (layoutUuid.equals(StringPool.BLANK)) {
22382                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
22383                            }
22384                            else {
22385                                    bindLayoutUuid = true;
22386    
22387                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
22388                            }
22389    
22390                            String sql = query.toString();
22391    
22392                            Session session = null;
22393    
22394                            try {
22395                                    session = openSession();
22396    
22397                                    Query q = session.createQuery(sql);
22398    
22399                                    QueryPos qPos = QueryPos.getInstance(q);
22400    
22401                                    qPos.add(groupId);
22402    
22403                                    qPos.add(classNameId);
22404    
22405                                    if (bindLayoutUuid) {
22406                                            qPos.add(layoutUuid);
22407                                    }
22408    
22409                                    count = (Long)q.uniqueResult();
22410    
22411                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22412                            }
22413                            catch (Exception e) {
22414                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22415    
22416                                    throw processException(e);
22417                            }
22418                            finally {
22419                                    closeSession(session);
22420                            }
22421                    }
22422    
22423                    return count.intValue();
22424            }
22425    
22426            /**
22427             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
22428             *
22429             * @param groupId the group ID
22430             * @param classNameId the class name ID
22431             * @param layoutUuid the layout uuid
22432             * @return the number of matching journal articles that the user has permission to view
22433             * @throws SystemException if a system exception occurred
22434             */
22435            @Override
22436            public int filterCountByG_C_L(long groupId, long classNameId,
22437                    String layoutUuid) throws SystemException {
22438                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22439                            return countByG_C_L(groupId, classNameId, layoutUuid);
22440                    }
22441    
22442                    StringBundler query = new StringBundler(4);
22443    
22444                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22445    
22446                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
22447    
22448                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
22449    
22450                    boolean bindLayoutUuid = false;
22451    
22452                    if (layoutUuid == null) {
22453                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
22454                    }
22455                    else if (layoutUuid.equals(StringPool.BLANK)) {
22456                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
22457                    }
22458                    else {
22459                            bindLayoutUuid = true;
22460    
22461                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
22462                    }
22463    
22464                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22465                                    JournalArticle.class.getName(),
22466                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22467    
22468                    Session session = null;
22469    
22470                    try {
22471                            session = openSession();
22472    
22473                            SQLQuery q = session.createSQLQuery(sql);
22474    
22475                            q.addScalar(COUNT_COLUMN_NAME,
22476                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22477    
22478                            QueryPos qPos = QueryPos.getInstance(q);
22479    
22480                            qPos.add(groupId);
22481    
22482                            qPos.add(classNameId);
22483    
22484                            if (bindLayoutUuid) {
22485                                    qPos.add(layoutUuid);
22486                            }
22487    
22488                            Long count = (Long)q.uniqueResult();
22489    
22490                            return count.intValue();
22491                    }
22492                    catch (Exception e) {
22493                            throw processException(e);
22494                    }
22495                    finally {
22496                            closeSession(session);
22497                    }
22498            }
22499    
22500            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
22501            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22502            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
22503            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
22504            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
22505            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22506                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22507                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22508                            "findByG_U_C",
22509                            new String[] {
22510                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
22511                                    
22512                            Integer.class.getName(), Integer.class.getName(),
22513                                    OrderByComparator.class.getName()
22514                            });
22515            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22516                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22517                            JournalArticleImpl.class,
22518                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
22519                            new String[] {
22520                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
22521                            },
22522                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22523                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
22524                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22525                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22526                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22527            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22528                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22529                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
22530                            new String[] {
22531                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
22532                            });
22533    
22534            /**
22535             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22536             *
22537             * @param groupId the group ID
22538             * @param userId the user ID
22539             * @param classNameId the class name ID
22540             * @return the matching journal articles
22541             * @throws SystemException if a system exception occurred
22542             */
22543            @Override
22544            public List<JournalArticle> findByG_U_C(long groupId, long userId,
22545                    long classNameId) throws SystemException {
22546                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
22547                            QueryUtil.ALL_POS, null);
22548            }
22549    
22550            /**
22551             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22552             *
22553             * <p>
22554             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22555             * </p>
22556             *
22557             * @param groupId the group ID
22558             * @param userId the user ID
22559             * @param classNameId the class name ID
22560             * @param start the lower bound of the range of journal articles
22561             * @param end the upper bound of the range of journal articles (not inclusive)
22562             * @return the range of matching journal articles
22563             * @throws SystemException if a system exception occurred
22564             */
22565            @Override
22566            public List<JournalArticle> findByG_U_C(long groupId, long userId,
22567                    long classNameId, int start, int end) throws SystemException {
22568                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
22569            }
22570    
22571            /**
22572             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22573             *
22574             * <p>
22575             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22576             * </p>
22577             *
22578             * @param groupId the group ID
22579             * @param userId the user ID
22580             * @param classNameId the class name ID
22581             * @param start the lower bound of the range of journal articles
22582             * @param end the upper bound of the range of journal articles (not inclusive)
22583             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22584             * @return the ordered range of matching journal articles
22585             * @throws SystemException if a system exception occurred
22586             */
22587            @Override
22588            public List<JournalArticle> findByG_U_C(long groupId, long userId,
22589                    long classNameId, int start, int end,
22590                    OrderByComparator orderByComparator) throws SystemException {
22591                    boolean pagination = true;
22592                    FinderPath finderPath = null;
22593                    Object[] finderArgs = null;
22594    
22595                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22596                                    (orderByComparator == null)) {
22597                            pagination = false;
22598                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
22599                            finderArgs = new Object[] { groupId, userId, classNameId };
22600                    }
22601                    else {
22602                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
22603                            finderArgs = new Object[] {
22604                                            groupId, userId, classNameId,
22605                                            
22606                                            start, end, orderByComparator
22607                                    };
22608                    }
22609    
22610                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22611                                    finderArgs, this);
22612    
22613                    if ((list != null) && !list.isEmpty()) {
22614                            for (JournalArticle journalArticle : list) {
22615                                    if ((groupId != journalArticle.getGroupId()) ||
22616                                                    (userId != journalArticle.getUserId()) ||
22617                                                    (classNameId != journalArticle.getClassNameId())) {
22618                                            list = null;
22619    
22620                                            break;
22621                                    }
22622                            }
22623                    }
22624    
22625                    if (list == null) {
22626                            StringBundler query = null;
22627    
22628                            if (orderByComparator != null) {
22629                                    query = new StringBundler(5 +
22630                                                    (orderByComparator.getOrderByFields().length * 3));
22631                            }
22632                            else {
22633                                    query = new StringBundler(5);
22634                            }
22635    
22636                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22637    
22638                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22639    
22640                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22641    
22642                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22643    
22644                            if (orderByComparator != null) {
22645                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22646                                            orderByComparator);
22647                            }
22648                            else
22649                             if (pagination) {
22650                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22651                            }
22652    
22653                            String sql = query.toString();
22654    
22655                            Session session = null;
22656    
22657                            try {
22658                                    session = openSession();
22659    
22660                                    Query q = session.createQuery(sql);
22661    
22662                                    QueryPos qPos = QueryPos.getInstance(q);
22663    
22664                                    qPos.add(groupId);
22665    
22666                                    qPos.add(userId);
22667    
22668                                    qPos.add(classNameId);
22669    
22670                                    if (!pagination) {
22671                                            list = (List<JournalArticle>)QueryUtil.list(q,
22672                                                            getDialect(), start, end, false);
22673    
22674                                            Collections.sort(list);
22675    
22676                                            list = new UnmodifiableList<JournalArticle>(list);
22677                                    }
22678                                    else {
22679                                            list = (List<JournalArticle>)QueryUtil.list(q,
22680                                                            getDialect(), start, end);
22681                                    }
22682    
22683                                    cacheResult(list);
22684    
22685                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22686                            }
22687                            catch (Exception e) {
22688                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22689    
22690                                    throw processException(e);
22691                            }
22692                            finally {
22693                                    closeSession(session);
22694                            }
22695                    }
22696    
22697                    return list;
22698            }
22699    
22700            /**
22701             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22702             *
22703             * @param groupId the group ID
22704             * @param userId the user ID
22705             * @param classNameId the class name ID
22706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22707             * @return the first matching journal article
22708             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22709             * @throws SystemException if a system exception occurred
22710             */
22711            @Override
22712            public JournalArticle findByG_U_C_First(long groupId, long userId,
22713                    long classNameId, OrderByComparator orderByComparator)
22714                    throws NoSuchArticleException, SystemException {
22715                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
22716                                    classNameId, orderByComparator);
22717    
22718                    if (journalArticle != null) {
22719                            return journalArticle;
22720                    }
22721    
22722                    StringBundler msg = new StringBundler(8);
22723    
22724                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22725    
22726                    msg.append("groupId=");
22727                    msg.append(groupId);
22728    
22729                    msg.append(", userId=");
22730                    msg.append(userId);
22731    
22732                    msg.append(", classNameId=");
22733                    msg.append(classNameId);
22734    
22735                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22736    
22737                    throw new NoSuchArticleException(msg.toString());
22738            }
22739    
22740            /**
22741             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22742             *
22743             * @param groupId the group ID
22744             * @param userId the user ID
22745             * @param classNameId the class name ID
22746             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22747             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
22748             * @throws SystemException if a system exception occurred
22749             */
22750            @Override
22751            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
22752                    long classNameId, OrderByComparator orderByComparator)
22753                    throws SystemException {
22754                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
22755                                    0, 1, orderByComparator);
22756    
22757                    if (!list.isEmpty()) {
22758                            return list.get(0);
22759                    }
22760    
22761                    return null;
22762            }
22763    
22764            /**
22765             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22766             *
22767             * @param groupId the group ID
22768             * @param userId the user ID
22769             * @param classNameId the class name ID
22770             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22771             * @return the last matching journal article
22772             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22773             * @throws SystemException if a system exception occurred
22774             */
22775            @Override
22776            public JournalArticle findByG_U_C_Last(long groupId, long userId,
22777                    long classNameId, OrderByComparator orderByComparator)
22778                    throws NoSuchArticleException, SystemException {
22779                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
22780                                    classNameId, orderByComparator);
22781    
22782                    if (journalArticle != null) {
22783                            return journalArticle;
22784                    }
22785    
22786                    StringBundler msg = new StringBundler(8);
22787    
22788                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22789    
22790                    msg.append("groupId=");
22791                    msg.append(groupId);
22792    
22793                    msg.append(", userId=");
22794                    msg.append(userId);
22795    
22796                    msg.append(", classNameId=");
22797                    msg.append(classNameId);
22798    
22799                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22800    
22801                    throw new NoSuchArticleException(msg.toString());
22802            }
22803    
22804            /**
22805             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22806             *
22807             * @param groupId the group ID
22808             * @param userId the user ID
22809             * @param classNameId the class name ID
22810             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22811             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
22812             * @throws SystemException if a system exception occurred
22813             */
22814            @Override
22815            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
22816                    long classNameId, OrderByComparator orderByComparator)
22817                    throws SystemException {
22818                    int count = countByG_U_C(groupId, userId, classNameId);
22819    
22820                    if (count == 0) {
22821                            return null;
22822                    }
22823    
22824                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
22825                                    count - 1, count, orderByComparator);
22826    
22827                    if (!list.isEmpty()) {
22828                            return list.get(0);
22829                    }
22830    
22831                    return null;
22832            }
22833    
22834            /**
22835             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22836             *
22837             * @param id the primary key of the current journal article
22838             * @param groupId the group ID
22839             * @param userId the user ID
22840             * @param classNameId the class name ID
22841             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22842             * @return the previous, current, and next journal article
22843             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22844             * @throws SystemException if a system exception occurred
22845             */
22846            @Override
22847            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
22848                    long userId, long classNameId, OrderByComparator orderByComparator)
22849                    throws NoSuchArticleException, SystemException {
22850                    JournalArticle journalArticle = findByPrimaryKey(id);
22851    
22852                    Session session = null;
22853    
22854                    try {
22855                            session = openSession();
22856    
22857                            JournalArticle[] array = new JournalArticleImpl[3];
22858    
22859                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
22860                                            userId, classNameId, orderByComparator, true);
22861    
22862                            array[1] = journalArticle;
22863    
22864                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
22865                                            userId, classNameId, orderByComparator, false);
22866    
22867                            return array;
22868                    }
22869                    catch (Exception e) {
22870                            throw processException(e);
22871                    }
22872                    finally {
22873                            closeSession(session);
22874                    }
22875            }
22876    
22877            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
22878                    JournalArticle journalArticle, long groupId, long userId,
22879                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
22880                    StringBundler query = null;
22881    
22882                    if (orderByComparator != null) {
22883                            query = new StringBundler(6 +
22884                                            (orderByComparator.getOrderByFields().length * 6));
22885                    }
22886                    else {
22887                            query = new StringBundler(3);
22888                    }
22889    
22890                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22891    
22892                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22893    
22894                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22895    
22896                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22897    
22898                    if (orderByComparator != null) {
22899                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22900    
22901                            if (orderByConditionFields.length > 0) {
22902                                    query.append(WHERE_AND);
22903                            }
22904    
22905                            for (int i = 0; i < orderByConditionFields.length; i++) {
22906                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22907                                    query.append(orderByConditionFields[i]);
22908    
22909                                    if ((i + 1) < orderByConditionFields.length) {
22910                                            if (orderByComparator.isAscending() ^ previous) {
22911                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22912                                            }
22913                                            else {
22914                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22915                                            }
22916                                    }
22917                                    else {
22918                                            if (orderByComparator.isAscending() ^ previous) {
22919                                                    query.append(WHERE_GREATER_THAN);
22920                                            }
22921                                            else {
22922                                                    query.append(WHERE_LESSER_THAN);
22923                                            }
22924                                    }
22925                            }
22926    
22927                            query.append(ORDER_BY_CLAUSE);
22928    
22929                            String[] orderByFields = orderByComparator.getOrderByFields();
22930    
22931                            for (int i = 0; i < orderByFields.length; i++) {
22932                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22933                                    query.append(orderByFields[i]);
22934    
22935                                    if ((i + 1) < orderByFields.length) {
22936                                            if (orderByComparator.isAscending() ^ previous) {
22937                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22938                                            }
22939                                            else {
22940                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22941                                            }
22942                                    }
22943                                    else {
22944                                            if (orderByComparator.isAscending() ^ previous) {
22945                                                    query.append(ORDER_BY_ASC);
22946                                            }
22947                                            else {
22948                                                    query.append(ORDER_BY_DESC);
22949                                            }
22950                                    }
22951                            }
22952                    }
22953                    else {
22954                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22955                    }
22956    
22957                    String sql = query.toString();
22958    
22959                    Query q = session.createQuery(sql);
22960    
22961                    q.setFirstResult(0);
22962                    q.setMaxResults(2);
22963    
22964                    QueryPos qPos = QueryPos.getInstance(q);
22965    
22966                    qPos.add(groupId);
22967    
22968                    qPos.add(userId);
22969    
22970                    qPos.add(classNameId);
22971    
22972                    if (orderByComparator != null) {
22973                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22974    
22975                            for (Object value : values) {
22976                                    qPos.add(value);
22977                            }
22978                    }
22979    
22980                    List<JournalArticle> list = q.list();
22981    
22982                    if (list.size() == 2) {
22983                            return list.get(1);
22984                    }
22985                    else {
22986                            return null;
22987                    }
22988            }
22989    
22990            /**
22991             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22992             *
22993             * @param groupId the group ID
22994             * @param userId the user ID
22995             * @param classNameId the class name ID
22996             * @return the matching journal articles that the user has permission to view
22997             * @throws SystemException if a system exception occurred
22998             */
22999            @Override
23000            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
23001                    long classNameId) throws SystemException {
23002                    return filterFindByG_U_C(groupId, userId, classNameId,
23003                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23004            }
23005    
23006            /**
23007             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
23008             *
23009             * <p>
23010             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23011             * </p>
23012             *
23013             * @param groupId the group ID
23014             * @param userId the user ID
23015             * @param classNameId the class name ID
23016             * @param start the lower bound of the range of journal articles
23017             * @param end the upper bound of the range of journal articles (not inclusive)
23018             * @return the range of matching journal articles that the user has permission to view
23019             * @throws SystemException if a system exception occurred
23020             */
23021            @Override
23022            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
23023                    long classNameId, int start, int end) throws SystemException {
23024                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
23025            }
23026    
23027            /**
23028             * 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;.
23029             *
23030             * <p>
23031             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23032             * </p>
23033             *
23034             * @param groupId the group ID
23035             * @param userId the user ID
23036             * @param classNameId the class name ID
23037             * @param start the lower bound of the range of journal articles
23038             * @param end the upper bound of the range of journal articles (not inclusive)
23039             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23040             * @return the ordered range of matching journal articles that the user has permission to view
23041             * @throws SystemException if a system exception occurred
23042             */
23043            @Override
23044            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
23045                    long classNameId, int start, int end,
23046                    OrderByComparator orderByComparator) throws SystemException {
23047                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23048                            return findByG_U_C(groupId, userId, classNameId, start, end,
23049                                    orderByComparator);
23050                    }
23051    
23052                    StringBundler query = null;
23053    
23054                    if (orderByComparator != null) {
23055                            query = new StringBundler(5 +
23056                                            (orderByComparator.getOrderByFields().length * 3));
23057                    }
23058                    else {
23059                            query = new StringBundler(5);
23060                    }
23061    
23062                    if (getDB().isSupportsInlineDistinct()) {
23063                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23064                    }
23065                    else {
23066                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23067                    }
23068    
23069                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
23070    
23071                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
23072    
23073                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
23074    
23075                    if (!getDB().isSupportsInlineDistinct()) {
23076                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23077                    }
23078    
23079                    if (orderByComparator != null) {
23080                            if (getDB().isSupportsInlineDistinct()) {
23081                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23082                                            orderByComparator, true);
23083                            }
23084                            else {
23085                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23086                                            orderByComparator, true);
23087                            }
23088                    }
23089                    else {
23090                            if (getDB().isSupportsInlineDistinct()) {
23091                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23092                            }
23093                            else {
23094                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23095                            }
23096                    }
23097    
23098                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23099                                    JournalArticle.class.getName(),
23100                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23101    
23102                    Session session = null;
23103    
23104                    try {
23105                            session = openSession();
23106    
23107                            SQLQuery q = session.createSQLQuery(sql);
23108    
23109                            if (getDB().isSupportsInlineDistinct()) {
23110                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23111                            }
23112                            else {
23113                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23114                            }
23115    
23116                            QueryPos qPos = QueryPos.getInstance(q);
23117    
23118                            qPos.add(groupId);
23119    
23120                            qPos.add(userId);
23121    
23122                            qPos.add(classNameId);
23123    
23124                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23125                                    end);
23126                    }
23127                    catch (Exception e) {
23128                            throw processException(e);
23129                    }
23130                    finally {
23131                            closeSession(session);
23132                    }
23133            }
23134    
23135            /**
23136             * 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;.
23137             *
23138             * @param id the primary key of the current journal article
23139             * @param groupId the group ID
23140             * @param userId the user ID
23141             * @param classNameId the class name ID
23142             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23143             * @return the previous, current, and next journal article
23144             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23145             * @throws SystemException if a system exception occurred
23146             */
23147            @Override
23148            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
23149                    long groupId, long userId, long classNameId,
23150                    OrderByComparator orderByComparator)
23151                    throws NoSuchArticleException, SystemException {
23152                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23153                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
23154                                    orderByComparator);
23155                    }
23156    
23157                    JournalArticle journalArticle = findByPrimaryKey(id);
23158    
23159                    Session session = null;
23160    
23161                    try {
23162                            session = openSession();
23163    
23164                            JournalArticle[] array = new JournalArticleImpl[3];
23165    
23166                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
23167                                            groupId, userId, classNameId, orderByComparator, true);
23168    
23169                            array[1] = journalArticle;
23170    
23171                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
23172                                            groupId, userId, classNameId, orderByComparator, false);
23173    
23174                            return array;
23175                    }
23176                    catch (Exception e) {
23177                            throw processException(e);
23178                    }
23179                    finally {
23180                            closeSession(session);
23181                    }
23182            }
23183    
23184            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
23185                    JournalArticle journalArticle, long groupId, long userId,
23186                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
23187                    StringBundler query = null;
23188    
23189                    if (orderByComparator != null) {
23190                            query = new StringBundler(6 +
23191                                            (orderByComparator.getOrderByFields().length * 6));
23192                    }
23193                    else {
23194                            query = new StringBundler(3);
23195                    }
23196    
23197                    if (getDB().isSupportsInlineDistinct()) {
23198                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23199                    }
23200                    else {
23201                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23202                    }
23203    
23204                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
23205    
23206                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
23207    
23208                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
23209    
23210                    if (!getDB().isSupportsInlineDistinct()) {
23211                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23212                    }
23213    
23214                    if (orderByComparator != null) {
23215                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23216    
23217                            if (orderByConditionFields.length > 0) {
23218                                    query.append(WHERE_AND);
23219                            }
23220    
23221                            for (int i = 0; i < orderByConditionFields.length; i++) {
23222                                    if (getDB().isSupportsInlineDistinct()) {
23223                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23224                                    }
23225                                    else {
23226                                            query.append(_ORDER_BY_ENTITY_TABLE);
23227                                    }
23228    
23229                                    query.append(orderByConditionFields[i]);
23230    
23231                                    if ((i + 1) < orderByConditionFields.length) {
23232                                            if (orderByComparator.isAscending() ^ previous) {
23233                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23234                                            }
23235                                            else {
23236                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23237                                            }
23238                                    }
23239                                    else {
23240                                            if (orderByComparator.isAscending() ^ previous) {
23241                                                    query.append(WHERE_GREATER_THAN);
23242                                            }
23243                                            else {
23244                                                    query.append(WHERE_LESSER_THAN);
23245                                            }
23246                                    }
23247                            }
23248    
23249                            query.append(ORDER_BY_CLAUSE);
23250    
23251                            String[] orderByFields = orderByComparator.getOrderByFields();
23252    
23253                            for (int i = 0; i < orderByFields.length; i++) {
23254                                    if (getDB().isSupportsInlineDistinct()) {
23255                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23256                                    }
23257                                    else {
23258                                            query.append(_ORDER_BY_ENTITY_TABLE);
23259                                    }
23260    
23261                                    query.append(orderByFields[i]);
23262    
23263                                    if ((i + 1) < orderByFields.length) {
23264                                            if (orderByComparator.isAscending() ^ previous) {
23265                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23266                                            }
23267                                            else {
23268                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23269                                            }
23270                                    }
23271                                    else {
23272                                            if (orderByComparator.isAscending() ^ previous) {
23273                                                    query.append(ORDER_BY_ASC);
23274                                            }
23275                                            else {
23276                                                    query.append(ORDER_BY_DESC);
23277                                            }
23278                                    }
23279                            }
23280                    }
23281                    else {
23282                            if (getDB().isSupportsInlineDistinct()) {
23283                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23284                            }
23285                            else {
23286                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23287                            }
23288                    }
23289    
23290                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23291                                    JournalArticle.class.getName(),
23292                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23293    
23294                    SQLQuery q = session.createSQLQuery(sql);
23295    
23296                    q.setFirstResult(0);
23297                    q.setMaxResults(2);
23298    
23299                    if (getDB().isSupportsInlineDistinct()) {
23300                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23301                    }
23302                    else {
23303                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23304                    }
23305    
23306                    QueryPos qPos = QueryPos.getInstance(q);
23307    
23308                    qPos.add(groupId);
23309    
23310                    qPos.add(userId);
23311    
23312                    qPos.add(classNameId);
23313    
23314                    if (orderByComparator != null) {
23315                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23316    
23317                            for (Object value : values) {
23318                                    qPos.add(value);
23319                            }
23320                    }
23321    
23322                    List<JournalArticle> list = q.list();
23323    
23324                    if (list.size() == 2) {
23325                            return list.get(1);
23326                    }
23327                    else {
23328                            return null;
23329                    }
23330            }
23331    
23332            /**
23333             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
23334             *
23335             * @param groupId the group ID
23336             * @param userId the user ID
23337             * @param classNameId the class name ID
23338             * @throws SystemException if a system exception occurred
23339             */
23340            @Override
23341            public void removeByG_U_C(long groupId, long userId, long classNameId)
23342                    throws SystemException {
23343                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
23344                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23345                            remove(journalArticle);
23346                    }
23347            }
23348    
23349            /**
23350             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
23351             *
23352             * @param groupId the group ID
23353             * @param userId the user ID
23354             * @param classNameId the class name ID
23355             * @return the number of matching journal articles
23356             * @throws SystemException if a system exception occurred
23357             */
23358            @Override
23359            public int countByG_U_C(long groupId, long userId, long classNameId)
23360                    throws SystemException {
23361                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
23362    
23363                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
23364    
23365                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23366                                    this);
23367    
23368                    if (count == null) {
23369                            StringBundler query = new StringBundler(4);
23370    
23371                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23372    
23373                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
23374    
23375                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
23376    
23377                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
23378    
23379                            String sql = query.toString();
23380    
23381                            Session session = null;
23382    
23383                            try {
23384                                    session = openSession();
23385    
23386                                    Query q = session.createQuery(sql);
23387    
23388                                    QueryPos qPos = QueryPos.getInstance(q);
23389    
23390                                    qPos.add(groupId);
23391    
23392                                    qPos.add(userId);
23393    
23394                                    qPos.add(classNameId);
23395    
23396                                    count = (Long)q.uniqueResult();
23397    
23398                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23399                            }
23400                            catch (Exception e) {
23401                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23402    
23403                                    throw processException(e);
23404                            }
23405                            finally {
23406                                    closeSession(session);
23407                            }
23408                    }
23409    
23410                    return count.intValue();
23411            }
23412    
23413            /**
23414             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
23415             *
23416             * @param groupId the group ID
23417             * @param userId the user ID
23418             * @param classNameId the class name ID
23419             * @return the number of matching journal articles that the user has permission to view
23420             * @throws SystemException if a system exception occurred
23421             */
23422            @Override
23423            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
23424                    throws SystemException {
23425                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23426                            return countByG_U_C(groupId, userId, classNameId);
23427                    }
23428    
23429                    StringBundler query = new StringBundler(4);
23430    
23431                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23432    
23433                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
23434    
23435                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
23436    
23437                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
23438    
23439                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23440                                    JournalArticle.class.getName(),
23441                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23442    
23443                    Session session = null;
23444    
23445                    try {
23446                            session = openSession();
23447    
23448                            SQLQuery q = session.createSQLQuery(sql);
23449    
23450                            q.addScalar(COUNT_COLUMN_NAME,
23451                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23452    
23453                            QueryPos qPos = QueryPos.getInstance(q);
23454    
23455                            qPos.add(groupId);
23456    
23457                            qPos.add(userId);
23458    
23459                            qPos.add(classNameId);
23460    
23461                            Long count = (Long)q.uniqueResult();
23462    
23463                            return count.intValue();
23464                    }
23465                    catch (Exception e) {
23466                            throw processException(e);
23467                    }
23468                    finally {
23469                            closeSession(session);
23470                    }
23471            }
23472    
23473            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
23474            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
23475            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
23476            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23477                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23478                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
23479                            new String[] {
23480                                    Long.class.getName(), String.class.getName(),
23481                                    Double.class.getName()
23482                            },
23483                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23484                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23485                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23486            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23487                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23488                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
23489                            new String[] {
23490                                    Long.class.getName(), String.class.getName(),
23491                                    Double.class.getName()
23492                            });
23493    
23494            /**
23495             * 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.
23496             *
23497             * @param groupId the group ID
23498             * @param articleId the article ID
23499             * @param version the version
23500             * @return the matching journal article
23501             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23502             * @throws SystemException if a system exception occurred
23503             */
23504            @Override
23505            public JournalArticle findByG_A_V(long groupId, String articleId,
23506                    double version) throws NoSuchArticleException, SystemException {
23507                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
23508    
23509                    if (journalArticle == null) {
23510                            StringBundler msg = new StringBundler(8);
23511    
23512                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23513    
23514                            msg.append("groupId=");
23515                            msg.append(groupId);
23516    
23517                            msg.append(", articleId=");
23518                            msg.append(articleId);
23519    
23520                            msg.append(", version=");
23521                            msg.append(version);
23522    
23523                            msg.append(StringPool.CLOSE_CURLY_BRACE);
23524    
23525                            if (_log.isWarnEnabled()) {
23526                                    _log.warn(msg.toString());
23527                            }
23528    
23529                            throw new NoSuchArticleException(msg.toString());
23530                    }
23531    
23532                    return journalArticle;
23533            }
23534    
23535            /**
23536             * 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.
23537             *
23538             * @param groupId the group ID
23539             * @param articleId the article ID
23540             * @param version the version
23541             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
23542             * @throws SystemException if a system exception occurred
23543             */
23544            @Override
23545            public JournalArticle fetchByG_A_V(long groupId, String articleId,
23546                    double version) throws SystemException {
23547                    return fetchByG_A_V(groupId, articleId, version, true);
23548            }
23549    
23550            /**
23551             * 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.
23552             *
23553             * @param groupId the group ID
23554             * @param articleId the article ID
23555             * @param version the version
23556             * @param retrieveFromCache whether to use the finder cache
23557             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
23558             * @throws SystemException if a system exception occurred
23559             */
23560            @Override
23561            public JournalArticle fetchByG_A_V(long groupId, String articleId,
23562                    double version, boolean retrieveFromCache) throws SystemException {
23563                    Object[] finderArgs = new Object[] { groupId, articleId, version };
23564    
23565                    Object result = null;
23566    
23567                    if (retrieveFromCache) {
23568                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
23569                                            finderArgs, this);
23570                    }
23571    
23572                    if (result instanceof JournalArticle) {
23573                            JournalArticle journalArticle = (JournalArticle)result;
23574    
23575                            if ((groupId != journalArticle.getGroupId()) ||
23576                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
23577                                            (version != journalArticle.getVersion())) {
23578                                    result = null;
23579                            }
23580                    }
23581    
23582                    if (result == null) {
23583                            StringBundler query = new StringBundler(5);
23584    
23585                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23586    
23587                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
23588    
23589                            boolean bindArticleId = false;
23590    
23591                            if (articleId == null) {
23592                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
23593                            }
23594                            else if (articleId.equals(StringPool.BLANK)) {
23595                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
23596                            }
23597                            else {
23598                                    bindArticleId = true;
23599    
23600                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
23601                            }
23602    
23603                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
23604    
23605                            String sql = query.toString();
23606    
23607                            Session session = null;
23608    
23609                            try {
23610                                    session = openSession();
23611    
23612                                    Query q = session.createQuery(sql);
23613    
23614                                    QueryPos qPos = QueryPos.getInstance(q);
23615    
23616                                    qPos.add(groupId);
23617    
23618                                    if (bindArticleId) {
23619                                            qPos.add(articleId);
23620                                    }
23621    
23622                                    qPos.add(version);
23623    
23624                                    List<JournalArticle> list = q.list();
23625    
23626                                    if (list.isEmpty()) {
23627                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
23628                                                    finderArgs, list);
23629                                    }
23630                                    else {
23631                                            JournalArticle journalArticle = list.get(0);
23632    
23633                                            result = journalArticle;
23634    
23635                                            cacheResult(journalArticle);
23636    
23637                                            if ((journalArticle.getGroupId() != groupId) ||
23638                                                            (journalArticle.getArticleId() == null) ||
23639                                                            !journalArticle.getArticleId().equals(articleId) ||
23640                                                            (journalArticle.getVersion() != version)) {
23641                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
23642                                                            finderArgs, journalArticle);
23643                                            }
23644                                    }
23645                            }
23646                            catch (Exception e) {
23647                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
23648                                            finderArgs);
23649    
23650                                    throw processException(e);
23651                            }
23652                            finally {
23653                                    closeSession(session);
23654                            }
23655                    }
23656    
23657                    if (result instanceof List<?>) {
23658                            return null;
23659                    }
23660                    else {
23661                            return (JournalArticle)result;
23662                    }
23663            }
23664    
23665            /**
23666             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
23667             *
23668             * @param groupId the group ID
23669             * @param articleId the article ID
23670             * @param version the version
23671             * @return the journal article that was removed
23672             * @throws SystemException if a system exception occurred
23673             */
23674            @Override
23675            public JournalArticle removeByG_A_V(long groupId, String articleId,
23676                    double version) throws NoSuchArticleException, SystemException {
23677                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
23678    
23679                    return remove(journalArticle);
23680            }
23681    
23682            /**
23683             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
23684             *
23685             * @param groupId the group ID
23686             * @param articleId the article ID
23687             * @param version the version
23688             * @return the number of matching journal articles
23689             * @throws SystemException if a system exception occurred
23690             */
23691            @Override
23692            public int countByG_A_V(long groupId, String articleId, double version)
23693                    throws SystemException {
23694                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
23695    
23696                    Object[] finderArgs = new Object[] { groupId, articleId, version };
23697    
23698                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23699                                    this);
23700    
23701                    if (count == null) {
23702                            StringBundler query = new StringBundler(4);
23703    
23704                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23705    
23706                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
23707    
23708                            boolean bindArticleId = false;
23709    
23710                            if (articleId == null) {
23711                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
23712                            }
23713                            else if (articleId.equals(StringPool.BLANK)) {
23714                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
23715                            }
23716                            else {
23717                                    bindArticleId = true;
23718    
23719                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
23720                            }
23721    
23722                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
23723    
23724                            String sql = query.toString();
23725    
23726                            Session session = null;
23727    
23728                            try {
23729                                    session = openSession();
23730    
23731                                    Query q = session.createQuery(sql);
23732    
23733                                    QueryPos qPos = QueryPos.getInstance(q);
23734    
23735                                    qPos.add(groupId);
23736    
23737                                    if (bindArticleId) {
23738                                            qPos.add(articleId);
23739                                    }
23740    
23741                                    qPos.add(version);
23742    
23743                                    count = (Long)q.uniqueResult();
23744    
23745                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23746                            }
23747                            catch (Exception e) {
23748                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23749    
23750                                    throw processException(e);
23751                            }
23752                            finally {
23753                                    closeSession(session);
23754                            }
23755                    }
23756    
23757                    return count.intValue();
23758            }
23759    
23760            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
23761            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
23762            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
23763            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
23764            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
23765            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23766                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23767                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23768                            "findByG_A_ST",
23769                            new String[] {
23770                                    Long.class.getName(), String.class.getName(),
23771                                    Integer.class.getName(),
23772                                    
23773                            Integer.class.getName(), Integer.class.getName(),
23774                                    OrderByComparator.class.getName()
23775                            });
23776            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
23777                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23778                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23779                            JournalArticleImpl.class,
23780                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
23781                            new String[] {
23782                                    Long.class.getName(), String.class.getName(),
23783                                    Integer.class.getName()
23784                            },
23785                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23786                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23787                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
23788                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23789            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23790                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23791                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
23792                            new String[] {
23793                                    Long.class.getName(), String.class.getName(),
23794                                    Integer.class.getName()
23795                            });
23796            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23797                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23798                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
23799                            new String[] {
23800                                    Long.class.getName(), String.class.getName(),
23801                                    Integer.class.getName()
23802                            });
23803    
23804            /**
23805             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23806             *
23807             * @param groupId the group ID
23808             * @param articleId the article ID
23809             * @param status the status
23810             * @return the matching journal articles
23811             * @throws SystemException if a system exception occurred
23812             */
23813            @Override
23814            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23815                    int status) throws SystemException {
23816                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
23817                            QueryUtil.ALL_POS, null);
23818            }
23819    
23820            /**
23821             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23822             *
23823             * <p>
23824             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23825             * </p>
23826             *
23827             * @param groupId the group ID
23828             * @param articleId the article ID
23829             * @param status the status
23830             * @param start the lower bound of the range of journal articles
23831             * @param end the upper bound of the range of journal articles (not inclusive)
23832             * @return the range of matching journal articles
23833             * @throws SystemException if a system exception occurred
23834             */
23835            @Override
23836            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23837                    int status, int start, int end) throws SystemException {
23838                    return findByG_A_ST(groupId, articleId, status, start, end, null);
23839            }
23840    
23841            /**
23842             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23843             *
23844             * <p>
23845             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23846             * </p>
23847             *
23848             * @param groupId the group ID
23849             * @param articleId the article ID
23850             * @param status the status
23851             * @param start the lower bound of the range of journal articles
23852             * @param end the upper bound of the range of journal articles (not inclusive)
23853             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23854             * @return the ordered range of matching journal articles
23855             * @throws SystemException if a system exception occurred
23856             */
23857            @Override
23858            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23859                    int status, int start, int end, OrderByComparator orderByComparator)
23860                    throws SystemException {
23861                    boolean pagination = true;
23862                    FinderPath finderPath = null;
23863                    Object[] finderArgs = null;
23864    
23865                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23866                                    (orderByComparator == null)) {
23867                            pagination = false;
23868                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
23869                            finderArgs = new Object[] { groupId, articleId, status };
23870                    }
23871                    else {
23872                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
23873                            finderArgs = new Object[] {
23874                                            groupId, articleId, status,
23875                                            
23876                                            start, end, orderByComparator
23877                                    };
23878                    }
23879    
23880                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23881                                    finderArgs, this);
23882    
23883                    if ((list != null) && !list.isEmpty()) {
23884                            for (JournalArticle journalArticle : list) {
23885                                    if ((groupId != journalArticle.getGroupId()) ||
23886                                                    !Validator.equals(articleId,
23887                                                            journalArticle.getArticleId()) ||
23888                                                    (status != journalArticle.getStatus())) {
23889                                            list = null;
23890    
23891                                            break;
23892                                    }
23893                            }
23894                    }
23895    
23896                    if (list == null) {
23897                            StringBundler query = null;
23898    
23899                            if (orderByComparator != null) {
23900                                    query = new StringBundler(5 +
23901                                                    (orderByComparator.getOrderByFields().length * 3));
23902                            }
23903                            else {
23904                                    query = new StringBundler(5);
23905                            }
23906    
23907                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23908    
23909                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23910    
23911                            boolean bindArticleId = false;
23912    
23913                            if (articleId == null) {
23914                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23915                            }
23916                            else if (articleId.equals(StringPool.BLANK)) {
23917                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23918                            }
23919                            else {
23920                                    bindArticleId = true;
23921    
23922                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23923                            }
23924    
23925                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23926    
23927                            if (orderByComparator != null) {
23928                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23929                                            orderByComparator);
23930                            }
23931                            else
23932                             if (pagination) {
23933                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23934                            }
23935    
23936                            String sql = query.toString();
23937    
23938                            Session session = null;
23939    
23940                            try {
23941                                    session = openSession();
23942    
23943                                    Query q = session.createQuery(sql);
23944    
23945                                    QueryPos qPos = QueryPos.getInstance(q);
23946    
23947                                    qPos.add(groupId);
23948    
23949                                    if (bindArticleId) {
23950                                            qPos.add(articleId);
23951                                    }
23952    
23953                                    qPos.add(status);
23954    
23955                                    if (!pagination) {
23956                                            list = (List<JournalArticle>)QueryUtil.list(q,
23957                                                            getDialect(), start, end, false);
23958    
23959                                            Collections.sort(list);
23960    
23961                                            list = new UnmodifiableList<JournalArticle>(list);
23962                                    }
23963                                    else {
23964                                            list = (List<JournalArticle>)QueryUtil.list(q,
23965                                                            getDialect(), start, end);
23966                                    }
23967    
23968                                    cacheResult(list);
23969    
23970                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23971                            }
23972                            catch (Exception e) {
23973                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23974    
23975                                    throw processException(e);
23976                            }
23977                            finally {
23978                                    closeSession(session);
23979                            }
23980                    }
23981    
23982                    return list;
23983            }
23984    
23985            /**
23986             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
23987             *
23988             * @param groupId the group ID
23989             * @param articleId the article ID
23990             * @param status the status
23991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23992             * @return the first matching journal article
23993             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23994             * @throws SystemException if a system exception occurred
23995             */
23996            @Override
23997            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
23998                    int status, OrderByComparator orderByComparator)
23999                    throws NoSuchArticleException, SystemException {
24000                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
24001                                    status, orderByComparator);
24002    
24003                    if (journalArticle != null) {
24004                            return journalArticle;
24005                    }
24006    
24007                    StringBundler msg = new StringBundler(8);
24008    
24009                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24010    
24011                    msg.append("groupId=");
24012                    msg.append(groupId);
24013    
24014                    msg.append(", articleId=");
24015                    msg.append(articleId);
24016    
24017                    msg.append(", status=");
24018                    msg.append(status);
24019    
24020                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24021    
24022                    throw new NoSuchArticleException(msg.toString());
24023            }
24024    
24025            /**
24026             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24027             *
24028             * @param groupId the group ID
24029             * @param articleId the article ID
24030             * @param status the status
24031             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24032             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24033             * @throws SystemException if a system exception occurred
24034             */
24035            @Override
24036            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
24037                    int status, OrderByComparator orderByComparator)
24038                    throws SystemException {
24039                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
24040                                    1, orderByComparator);
24041    
24042                    if (!list.isEmpty()) {
24043                            return list.get(0);
24044                    }
24045    
24046                    return null;
24047            }
24048    
24049            /**
24050             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24051             *
24052             * @param groupId the group ID
24053             * @param articleId the article ID
24054             * @param status the status
24055             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24056             * @return the last matching journal article
24057             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24058             * @throws SystemException if a system exception occurred
24059             */
24060            @Override
24061            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
24062                    int status, OrderByComparator orderByComparator)
24063                    throws NoSuchArticleException, SystemException {
24064                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
24065                                    status, orderByComparator);
24066    
24067                    if (journalArticle != null) {
24068                            return journalArticle;
24069                    }
24070    
24071                    StringBundler msg = new StringBundler(8);
24072    
24073                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24074    
24075                    msg.append("groupId=");
24076                    msg.append(groupId);
24077    
24078                    msg.append(", articleId=");
24079                    msg.append(articleId);
24080    
24081                    msg.append(", status=");
24082                    msg.append(status);
24083    
24084                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24085    
24086                    throw new NoSuchArticleException(msg.toString());
24087            }
24088    
24089            /**
24090             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24091             *
24092             * @param groupId the group ID
24093             * @param articleId the article ID
24094             * @param status the status
24095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24096             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24097             * @throws SystemException if a system exception occurred
24098             */
24099            @Override
24100            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
24101                    int status, OrderByComparator orderByComparator)
24102                    throws SystemException {
24103                    int count = countByG_A_ST(groupId, articleId, status);
24104    
24105                    if (count == 0) {
24106                            return null;
24107                    }
24108    
24109                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
24110                                    count - 1, count, orderByComparator);
24111    
24112                    if (!list.isEmpty()) {
24113                            return list.get(0);
24114                    }
24115    
24116                    return null;
24117            }
24118    
24119            /**
24120             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24121             *
24122             * @param id the primary key of the current journal article
24123             * @param groupId the group ID
24124             * @param articleId the article ID
24125             * @param status the status
24126             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24127             * @return the previous, current, and next journal article
24128             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24129             * @throws SystemException if a system exception occurred
24130             */
24131            @Override
24132            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
24133                    String articleId, int status, OrderByComparator orderByComparator)
24134                    throws NoSuchArticleException, SystemException {
24135                    JournalArticle journalArticle = findByPrimaryKey(id);
24136    
24137                    Session session = null;
24138    
24139                    try {
24140                            session = openSession();
24141    
24142                            JournalArticle[] array = new JournalArticleImpl[3];
24143    
24144                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
24145                                            groupId, articleId, status, orderByComparator, true);
24146    
24147                            array[1] = journalArticle;
24148    
24149                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
24150                                            groupId, articleId, status, orderByComparator, false);
24151    
24152                            return array;
24153                    }
24154                    catch (Exception e) {
24155                            throw processException(e);
24156                    }
24157                    finally {
24158                            closeSession(session);
24159                    }
24160            }
24161    
24162            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
24163                    JournalArticle journalArticle, long groupId, String articleId,
24164                    int status, OrderByComparator orderByComparator, boolean previous) {
24165                    StringBundler query = null;
24166    
24167                    if (orderByComparator != null) {
24168                            query = new StringBundler(6 +
24169                                            (orderByComparator.getOrderByFields().length * 6));
24170                    }
24171                    else {
24172                            query = new StringBundler(3);
24173                    }
24174    
24175                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24176    
24177                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24178    
24179                    boolean bindArticleId = false;
24180    
24181                    if (articleId == null) {
24182                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24183                    }
24184                    else if (articleId.equals(StringPool.BLANK)) {
24185                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24186                    }
24187                    else {
24188                            bindArticleId = true;
24189    
24190                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24191                    }
24192    
24193                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24194    
24195                    if (orderByComparator != null) {
24196                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24197    
24198                            if (orderByConditionFields.length > 0) {
24199                                    query.append(WHERE_AND);
24200                            }
24201    
24202                            for (int i = 0; i < orderByConditionFields.length; i++) {
24203                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24204                                    query.append(orderByConditionFields[i]);
24205    
24206                                    if ((i + 1) < orderByConditionFields.length) {
24207                                            if (orderByComparator.isAscending() ^ previous) {
24208                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24209                                            }
24210                                            else {
24211                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24212                                            }
24213                                    }
24214                                    else {
24215                                            if (orderByComparator.isAscending() ^ previous) {
24216                                                    query.append(WHERE_GREATER_THAN);
24217                                            }
24218                                            else {
24219                                                    query.append(WHERE_LESSER_THAN);
24220                                            }
24221                                    }
24222                            }
24223    
24224                            query.append(ORDER_BY_CLAUSE);
24225    
24226                            String[] orderByFields = orderByComparator.getOrderByFields();
24227    
24228                            for (int i = 0; i < orderByFields.length; i++) {
24229                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24230                                    query.append(orderByFields[i]);
24231    
24232                                    if ((i + 1) < orderByFields.length) {
24233                                            if (orderByComparator.isAscending() ^ previous) {
24234                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24235                                            }
24236                                            else {
24237                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24238                                            }
24239                                    }
24240                                    else {
24241                                            if (orderByComparator.isAscending() ^ previous) {
24242                                                    query.append(ORDER_BY_ASC);
24243                                            }
24244                                            else {
24245                                                    query.append(ORDER_BY_DESC);
24246                                            }
24247                                    }
24248                            }
24249                    }
24250                    else {
24251                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24252                    }
24253    
24254                    String sql = query.toString();
24255    
24256                    Query q = session.createQuery(sql);
24257    
24258                    q.setFirstResult(0);
24259                    q.setMaxResults(2);
24260    
24261                    QueryPos qPos = QueryPos.getInstance(q);
24262    
24263                    qPos.add(groupId);
24264    
24265                    if (bindArticleId) {
24266                            qPos.add(articleId);
24267                    }
24268    
24269                    qPos.add(status);
24270    
24271                    if (orderByComparator != null) {
24272                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24273    
24274                            for (Object value : values) {
24275                                    qPos.add(value);
24276                            }
24277                    }
24278    
24279                    List<JournalArticle> list = q.list();
24280    
24281                    if (list.size() == 2) {
24282                            return list.get(1);
24283                    }
24284                    else {
24285                            return null;
24286                    }
24287            }
24288    
24289            /**
24290             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
24291             *
24292             * @param groupId the group ID
24293             * @param articleId the article ID
24294             * @param status the status
24295             * @return the matching journal articles that the user has permission to view
24296             * @throws SystemException if a system exception occurred
24297             */
24298            @Override
24299            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24300                    String articleId, int status) throws SystemException {
24301                    return filterFindByG_A_ST(groupId, articleId, status,
24302                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24303            }
24304    
24305            /**
24306             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
24307             *
24308             * <p>
24309             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24310             * </p>
24311             *
24312             * @param groupId the group ID
24313             * @param articleId the article ID
24314             * @param status the status
24315             * @param start the lower bound of the range of journal articles
24316             * @param end the upper bound of the range of journal articles (not inclusive)
24317             * @return the range of matching journal articles that the user has permission to view
24318             * @throws SystemException if a system exception occurred
24319             */
24320            @Override
24321            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24322                    String articleId, int status, int start, int end)
24323                    throws SystemException {
24324                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
24325            }
24326    
24327            /**
24328             * 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;.
24329             *
24330             * <p>
24331             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24332             * </p>
24333             *
24334             * @param groupId the group ID
24335             * @param articleId the article ID
24336             * @param status the status
24337             * @param start the lower bound of the range of journal articles
24338             * @param end the upper bound of the range of journal articles (not inclusive)
24339             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24340             * @return the ordered range of matching journal articles that the user has permission to view
24341             * @throws SystemException if a system exception occurred
24342             */
24343            @Override
24344            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24345                    String articleId, int status, int start, int end,
24346                    OrderByComparator orderByComparator) throws SystemException {
24347                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24348                            return findByG_A_ST(groupId, articleId, status, start, end,
24349                                    orderByComparator);
24350                    }
24351    
24352                    StringBundler query = null;
24353    
24354                    if (orderByComparator != null) {
24355                            query = new StringBundler(5 +
24356                                            (orderByComparator.getOrderByFields().length * 3));
24357                    }
24358                    else {
24359                            query = new StringBundler(5);
24360                    }
24361    
24362                    if (getDB().isSupportsInlineDistinct()) {
24363                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24364                    }
24365                    else {
24366                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24367                    }
24368    
24369                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24370    
24371                    boolean bindArticleId = false;
24372    
24373                    if (articleId == null) {
24374                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24375                    }
24376                    else if (articleId.equals(StringPool.BLANK)) {
24377                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24378                    }
24379                    else {
24380                            bindArticleId = true;
24381    
24382                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24383                    }
24384    
24385                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24386    
24387                    if (!getDB().isSupportsInlineDistinct()) {
24388                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24389                    }
24390    
24391                    if (orderByComparator != null) {
24392                            if (getDB().isSupportsInlineDistinct()) {
24393                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24394                                            orderByComparator, true);
24395                            }
24396                            else {
24397                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24398                                            orderByComparator, true);
24399                            }
24400                    }
24401                    else {
24402                            if (getDB().isSupportsInlineDistinct()) {
24403                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24404                            }
24405                            else {
24406                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24407                            }
24408                    }
24409    
24410                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24411                                    JournalArticle.class.getName(),
24412                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24413    
24414                    Session session = null;
24415    
24416                    try {
24417                            session = openSession();
24418    
24419                            SQLQuery q = session.createSQLQuery(sql);
24420    
24421                            if (getDB().isSupportsInlineDistinct()) {
24422                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24423                            }
24424                            else {
24425                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24426                            }
24427    
24428                            QueryPos qPos = QueryPos.getInstance(q);
24429    
24430                            qPos.add(groupId);
24431    
24432                            if (bindArticleId) {
24433                                    qPos.add(articleId);
24434                            }
24435    
24436                            qPos.add(status);
24437    
24438                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24439                                    end);
24440                    }
24441                    catch (Exception e) {
24442                            throw processException(e);
24443                    }
24444                    finally {
24445                            closeSession(session);
24446                    }
24447            }
24448    
24449            /**
24450             * 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;.
24451             *
24452             * @param id the primary key of the current journal article
24453             * @param groupId the group ID
24454             * @param articleId the article ID
24455             * @param status the status
24456             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24457             * @return the previous, current, and next journal article
24458             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24459             * @throws SystemException if a system exception occurred
24460             */
24461            @Override
24462            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
24463                    long groupId, String articleId, int status,
24464                    OrderByComparator orderByComparator)
24465                    throws NoSuchArticleException, SystemException {
24466                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24467                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
24468                                    orderByComparator);
24469                    }
24470    
24471                    JournalArticle journalArticle = findByPrimaryKey(id);
24472    
24473                    Session session = null;
24474    
24475                    try {
24476                            session = openSession();
24477    
24478                            JournalArticle[] array = new JournalArticleImpl[3];
24479    
24480                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
24481                                            groupId, articleId, status, orderByComparator, true);
24482    
24483                            array[1] = journalArticle;
24484    
24485                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
24486                                            groupId, articleId, status, orderByComparator, false);
24487    
24488                            return array;
24489                    }
24490                    catch (Exception e) {
24491                            throw processException(e);
24492                    }
24493                    finally {
24494                            closeSession(session);
24495                    }
24496            }
24497    
24498            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
24499                    JournalArticle journalArticle, long groupId, String articleId,
24500                    int status, OrderByComparator orderByComparator, boolean previous) {
24501                    StringBundler query = null;
24502    
24503                    if (orderByComparator != null) {
24504                            query = new StringBundler(6 +
24505                                            (orderByComparator.getOrderByFields().length * 6));
24506                    }
24507                    else {
24508                            query = new StringBundler(3);
24509                    }
24510    
24511                    if (getDB().isSupportsInlineDistinct()) {
24512                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24513                    }
24514                    else {
24515                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24516                    }
24517    
24518                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24519    
24520                    boolean bindArticleId = false;
24521    
24522                    if (articleId == null) {
24523                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24524                    }
24525                    else if (articleId.equals(StringPool.BLANK)) {
24526                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24527                    }
24528                    else {
24529                            bindArticleId = true;
24530    
24531                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24532                    }
24533    
24534                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24535    
24536                    if (!getDB().isSupportsInlineDistinct()) {
24537                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24538                    }
24539    
24540                    if (orderByComparator != null) {
24541                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24542    
24543                            if (orderByConditionFields.length > 0) {
24544                                    query.append(WHERE_AND);
24545                            }
24546    
24547                            for (int i = 0; i < orderByConditionFields.length; i++) {
24548                                    if (getDB().isSupportsInlineDistinct()) {
24549                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24550                                    }
24551                                    else {
24552                                            query.append(_ORDER_BY_ENTITY_TABLE);
24553                                    }
24554    
24555                                    query.append(orderByConditionFields[i]);
24556    
24557                                    if ((i + 1) < orderByConditionFields.length) {
24558                                            if (orderByComparator.isAscending() ^ previous) {
24559                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24560                                            }
24561                                            else {
24562                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24563                                            }
24564                                    }
24565                                    else {
24566                                            if (orderByComparator.isAscending() ^ previous) {
24567                                                    query.append(WHERE_GREATER_THAN);
24568                                            }
24569                                            else {
24570                                                    query.append(WHERE_LESSER_THAN);
24571                                            }
24572                                    }
24573                            }
24574    
24575                            query.append(ORDER_BY_CLAUSE);
24576    
24577                            String[] orderByFields = orderByComparator.getOrderByFields();
24578    
24579                            for (int i = 0; i < orderByFields.length; i++) {
24580                                    if (getDB().isSupportsInlineDistinct()) {
24581                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24582                                    }
24583                                    else {
24584                                            query.append(_ORDER_BY_ENTITY_TABLE);
24585                                    }
24586    
24587                                    query.append(orderByFields[i]);
24588    
24589                                    if ((i + 1) < orderByFields.length) {
24590                                            if (orderByComparator.isAscending() ^ previous) {
24591                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24592                                            }
24593                                            else {
24594                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24595                                            }
24596                                    }
24597                                    else {
24598                                            if (orderByComparator.isAscending() ^ previous) {
24599                                                    query.append(ORDER_BY_ASC);
24600                                            }
24601                                            else {
24602                                                    query.append(ORDER_BY_DESC);
24603                                            }
24604                                    }
24605                            }
24606                    }
24607                    else {
24608                            if (getDB().isSupportsInlineDistinct()) {
24609                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24610                            }
24611                            else {
24612                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24613                            }
24614                    }
24615    
24616                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24617                                    JournalArticle.class.getName(),
24618                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24619    
24620                    SQLQuery q = session.createSQLQuery(sql);
24621    
24622                    q.setFirstResult(0);
24623                    q.setMaxResults(2);
24624    
24625                    if (getDB().isSupportsInlineDistinct()) {
24626                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24627                    }
24628                    else {
24629                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24630                    }
24631    
24632                    QueryPos qPos = QueryPos.getInstance(q);
24633    
24634                    qPos.add(groupId);
24635    
24636                    if (bindArticleId) {
24637                            qPos.add(articleId);
24638                    }
24639    
24640                    qPos.add(status);
24641    
24642                    if (orderByComparator != null) {
24643                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24644    
24645                            for (Object value : values) {
24646                                    qPos.add(value);
24647                            }
24648                    }
24649    
24650                    List<JournalArticle> list = q.list();
24651    
24652                    if (list.size() == 2) {
24653                            return list.get(1);
24654                    }
24655                    else {
24656                            return null;
24657                    }
24658            }
24659    
24660            /**
24661             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
24662             *
24663             * @param groupId the group ID
24664             * @param articleId the article ID
24665             * @param statuses the statuses
24666             * @return the matching journal articles that the user has permission to view
24667             * @throws SystemException if a system exception occurred
24668             */
24669            @Override
24670            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24671                    String articleId, int[] statuses) throws SystemException {
24672                    return filterFindByG_A_ST(groupId, articleId, statuses,
24673                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24674            }
24675    
24676            /**
24677             * 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;.
24678             *
24679             * <p>
24680             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24681             * </p>
24682             *
24683             * @param groupId the group ID
24684             * @param articleId the article ID
24685             * @param statuses the statuses
24686             * @param start the lower bound of the range of journal articles
24687             * @param end the upper bound of the range of journal articles (not inclusive)
24688             * @return the range of matching journal articles that the user has permission to view
24689             * @throws SystemException if a system exception occurred
24690             */
24691            @Override
24692            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24693                    String articleId, int[] statuses, int start, int end)
24694                    throws SystemException {
24695                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
24696            }
24697    
24698            /**
24699             * 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;.
24700             *
24701             * <p>
24702             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24703             * </p>
24704             *
24705             * @param groupId the group ID
24706             * @param articleId the article ID
24707             * @param statuses the statuses
24708             * @param start the lower bound of the range of journal articles
24709             * @param end the upper bound of the range of journal articles (not inclusive)
24710             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24711             * @return the ordered range of matching journal articles that the user has permission to view
24712             * @throws SystemException if a system exception occurred
24713             */
24714            @Override
24715            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24716                    String articleId, int[] statuses, int start, int end,
24717                    OrderByComparator orderByComparator) throws SystemException {
24718                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24719                            return findByG_A_ST(groupId, articleId, statuses, start, end,
24720                                    orderByComparator);
24721                    }
24722    
24723                    StringBundler query = new StringBundler();
24724    
24725                    if (getDB().isSupportsInlineDistinct()) {
24726                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24727                    }
24728                    else {
24729                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24730                    }
24731    
24732                    boolean conjunctionable = false;
24733    
24734                    if (conjunctionable) {
24735                            query.append(WHERE_AND);
24736                    }
24737    
24738                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
24739    
24740                    conjunctionable = true;
24741    
24742                    if (conjunctionable) {
24743                            query.append(WHERE_AND);
24744                    }
24745    
24746                    if (articleId == null) {
24747                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
24748                    }
24749                    else if (articleId.equals(StringPool.BLANK)) {
24750                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
24751                    }
24752                    else {
24753                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
24754                    }
24755    
24756                    conjunctionable = true;
24757    
24758                    if ((statuses == null) || (statuses.length > 0)) {
24759                            if (conjunctionable) {
24760                                    query.append(WHERE_AND);
24761                            }
24762    
24763                            query.append(StringPool.OPEN_PARENTHESIS);
24764    
24765                            for (int i = 0; i < statuses.length; i++) {
24766                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
24767    
24768                                    if ((i + 1) < statuses.length) {
24769                                            query.append(WHERE_OR);
24770                                    }
24771                            }
24772    
24773                            query.append(StringPool.CLOSE_PARENTHESIS);
24774    
24775                            conjunctionable = true;
24776                    }
24777    
24778                    if (!getDB().isSupportsInlineDistinct()) {
24779                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24780                    }
24781    
24782                    if (orderByComparator != null) {
24783                            if (getDB().isSupportsInlineDistinct()) {
24784                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24785                                            orderByComparator, true);
24786                            }
24787                            else {
24788                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24789                                            orderByComparator, true);
24790                            }
24791                    }
24792                    else {
24793                            if (getDB().isSupportsInlineDistinct()) {
24794                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24795                            }
24796                            else {
24797                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24798                            }
24799                    }
24800    
24801                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24802                                    JournalArticle.class.getName(),
24803                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24804    
24805                    Session session = null;
24806    
24807                    try {
24808                            session = openSession();
24809    
24810                            SQLQuery q = session.createSQLQuery(sql);
24811    
24812                            if (getDB().isSupportsInlineDistinct()) {
24813                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24814                            }
24815                            else {
24816                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24817                            }
24818    
24819                            QueryPos qPos = QueryPos.getInstance(q);
24820    
24821                            qPos.add(groupId);
24822    
24823                            if (articleId != null) {
24824                                    qPos.add(articleId);
24825                            }
24826    
24827                            if (statuses != null) {
24828                                    qPos.add(statuses);
24829                            }
24830    
24831                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24832                                    end);
24833                    }
24834                    catch (Exception e) {
24835                            throw processException(e);
24836                    }
24837                    finally {
24838                            closeSession(session);
24839                    }
24840            }
24841    
24842            /**
24843             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
24844             *
24845             * <p>
24846             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24847             * </p>
24848             *
24849             * @param groupId the group ID
24850             * @param articleId the article ID
24851             * @param statuses the statuses
24852             * @return the matching journal articles
24853             * @throws SystemException if a system exception occurred
24854             */
24855            @Override
24856            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24857                    int[] statuses) throws SystemException {
24858                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
24859                            QueryUtil.ALL_POS, null);
24860            }
24861    
24862            /**
24863             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#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 statuses the statuses
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             * @return the range of matching journal articles
24875             * @throws SystemException if a system exception occurred
24876             */
24877            @Override
24878            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24879                    int[] statuses, int start, int end) throws SystemException {
24880                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
24881            }
24882    
24883            /**
24884             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
24885             *
24886             * <p>
24887             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24888             * </p>
24889             *
24890             * @param groupId the group ID
24891             * @param articleId the article ID
24892             * @param statuses the statuses
24893             * @param start the lower bound of the range of journal articles
24894             * @param end the upper bound of the range of journal articles (not inclusive)
24895             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24896             * @return the ordered range of matching journal articles
24897             * @throws SystemException if a system exception occurred
24898             */
24899            @Override
24900            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24901                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
24902                    throws SystemException {
24903                    if ((statuses != null) && (statuses.length == 1)) {
24904                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
24905                                    orderByComparator);
24906                    }
24907    
24908                    boolean pagination = true;
24909                    Object[] finderArgs = null;
24910    
24911                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24912                                    (orderByComparator == null)) {
24913                            pagination = false;
24914                            finderArgs = new Object[] {
24915                                            groupId, articleId, StringUtil.merge(statuses)
24916                                    };
24917                    }
24918                    else {
24919                            finderArgs = new Object[] {
24920                                            groupId, articleId, StringUtil.merge(statuses),
24921                                            
24922                                            start, end, orderByComparator
24923                                    };
24924                    }
24925    
24926                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
24927                                    finderArgs, this);
24928    
24929                    if ((list != null) && !list.isEmpty()) {
24930                            for (JournalArticle journalArticle : list) {
24931                                    if ((groupId != journalArticle.getGroupId()) ||
24932                                                    !Validator.equals(articleId,
24933                                                            journalArticle.getArticleId()) ||
24934                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
24935                                            list = null;
24936    
24937                                            break;
24938                                    }
24939                            }
24940                    }
24941    
24942                    if (list == null) {
24943                            StringBundler query = new StringBundler();
24944    
24945                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24946    
24947                            boolean conjunctionable = false;
24948    
24949                            if (conjunctionable) {
24950                                    query.append(WHERE_AND);
24951                            }
24952    
24953                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
24954    
24955                            conjunctionable = true;
24956    
24957                            if (conjunctionable) {
24958                                    query.append(WHERE_AND);
24959                            }
24960    
24961                            if (articleId == null) {
24962                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
24963                            }
24964                            else if (articleId.equals(StringPool.BLANK)) {
24965                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
24966                            }
24967                            else {
24968                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
24969                            }
24970    
24971                            conjunctionable = true;
24972    
24973                            if ((statuses == null) || (statuses.length > 0)) {
24974                                    if (conjunctionable) {
24975                                            query.append(WHERE_AND);
24976                                    }
24977    
24978                                    query.append(StringPool.OPEN_PARENTHESIS);
24979    
24980                                    for (int i = 0; i < statuses.length; i++) {
24981                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
24982    
24983                                            if ((i + 1) < statuses.length) {
24984                                                    query.append(WHERE_OR);
24985                                            }
24986                                    }
24987    
24988                                    query.append(StringPool.CLOSE_PARENTHESIS);
24989    
24990                                    conjunctionable = true;
24991                            }
24992    
24993                            if (orderByComparator != null) {
24994                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24995                                            orderByComparator);
24996                            }
24997                            else
24998                             if (pagination) {
24999                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25000                            }
25001    
25002                            String sql = query.toString();
25003    
25004                            Session session = null;
25005    
25006                            try {
25007                                    session = openSession();
25008    
25009                                    Query q = session.createQuery(sql);
25010    
25011                                    QueryPos qPos = QueryPos.getInstance(q);
25012    
25013                                    qPos.add(groupId);
25014    
25015                                    if (articleId != null) {
25016                                            qPos.add(articleId);
25017                                    }
25018    
25019                                    if (statuses != null) {
25020                                            qPos.add(statuses);
25021                                    }
25022    
25023                                    if (!pagination) {
25024                                            list = (List<JournalArticle>)QueryUtil.list(q,
25025                                                            getDialect(), start, end, false);
25026    
25027                                            Collections.sort(list);
25028    
25029                                            list = new UnmodifiableList<JournalArticle>(list);
25030                                    }
25031                                    else {
25032                                            list = (List<JournalArticle>)QueryUtil.list(q,
25033                                                            getDialect(), start, end);
25034                                    }
25035    
25036                                    cacheResult(list);
25037    
25038                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25039                                            finderArgs, list);
25040                            }
25041                            catch (Exception e) {
25042                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25043                                            finderArgs);
25044    
25045                                    throw processException(e);
25046                            }
25047                            finally {
25048                                    closeSession(session);
25049                            }
25050                    }
25051    
25052                    return list;
25053            }
25054    
25055            /**
25056             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
25057             *
25058             * @param groupId the group ID
25059             * @param articleId the article ID
25060             * @param status the status
25061             * @throws SystemException if a system exception occurred
25062             */
25063            @Override
25064            public void removeByG_A_ST(long groupId, String articleId, int status)
25065                    throws SystemException {
25066                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
25067                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
25068                            remove(journalArticle);
25069                    }
25070            }
25071    
25072            /**
25073             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25074             *
25075             * @param groupId the group ID
25076             * @param articleId the article ID
25077             * @param status the status
25078             * @return the number of matching journal articles
25079             * @throws SystemException if a system exception occurred
25080             */
25081            @Override
25082            public int countByG_A_ST(long groupId, String articleId, int status)
25083                    throws SystemException {
25084                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
25085    
25086                    Object[] finderArgs = new Object[] { groupId, articleId, status };
25087    
25088                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25089                                    this);
25090    
25091                    if (count == null) {
25092                            StringBundler query = new StringBundler(4);
25093    
25094                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25095    
25096                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25097    
25098                            boolean bindArticleId = false;
25099    
25100                            if (articleId == null) {
25101                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25102                            }
25103                            else if (articleId.equals(StringPool.BLANK)) {
25104                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25105                            }
25106                            else {
25107                                    bindArticleId = true;
25108    
25109                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25110                            }
25111    
25112                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25113    
25114                            String sql = query.toString();
25115    
25116                            Session session = null;
25117    
25118                            try {
25119                                    session = openSession();
25120    
25121                                    Query q = session.createQuery(sql);
25122    
25123                                    QueryPos qPos = QueryPos.getInstance(q);
25124    
25125                                    qPos.add(groupId);
25126    
25127                                    if (bindArticleId) {
25128                                            qPos.add(articleId);
25129                                    }
25130    
25131                                    qPos.add(status);
25132    
25133                                    count = (Long)q.uniqueResult();
25134    
25135                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25136                            }
25137                            catch (Exception e) {
25138                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25139    
25140                                    throw processException(e);
25141                            }
25142                            finally {
25143                                    closeSession(session);
25144                            }
25145                    }
25146    
25147                    return count.intValue();
25148            }
25149    
25150            /**
25151             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25152             *
25153             * @param groupId the group ID
25154             * @param articleId the article ID
25155             * @param statuses the statuses
25156             * @return the number of matching journal articles
25157             * @throws SystemException if a system exception occurred
25158             */
25159            @Override
25160            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
25161                    throws SystemException {
25162                    Object[] finderArgs = new Object[] {
25163                                    groupId, articleId, StringUtil.merge(statuses)
25164                            };
25165    
25166                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25167                                    finderArgs, this);
25168    
25169                    if (count == null) {
25170                            StringBundler query = new StringBundler();
25171    
25172                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25173    
25174                            boolean conjunctionable = false;
25175    
25176                            if (conjunctionable) {
25177                                    query.append(WHERE_AND);
25178                            }
25179    
25180                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
25181    
25182                            conjunctionable = true;
25183    
25184                            if (conjunctionable) {
25185                                    query.append(WHERE_AND);
25186                            }
25187    
25188                            if (articleId == null) {
25189                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
25190                            }
25191                            else if (articleId.equals(StringPool.BLANK)) {
25192                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
25193                            }
25194                            else {
25195                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
25196                            }
25197    
25198                            conjunctionable = true;
25199    
25200                            if ((statuses == null) || (statuses.length > 0)) {
25201                                    if (conjunctionable) {
25202                                            query.append(WHERE_AND);
25203                                    }
25204    
25205                                    query.append(StringPool.OPEN_PARENTHESIS);
25206    
25207                                    for (int i = 0; i < statuses.length; i++) {
25208                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
25209    
25210                                            if ((i + 1) < statuses.length) {
25211                                                    query.append(WHERE_OR);
25212                                            }
25213                                    }
25214    
25215                                    query.append(StringPool.CLOSE_PARENTHESIS);
25216    
25217                                    conjunctionable = true;
25218                            }
25219    
25220                            String sql = query.toString();
25221    
25222                            Session session = null;
25223    
25224                            try {
25225                                    session = openSession();
25226    
25227                                    Query q = session.createQuery(sql);
25228    
25229                                    QueryPos qPos = QueryPos.getInstance(q);
25230    
25231                                    qPos.add(groupId);
25232    
25233                                    if (articleId != null) {
25234                                            qPos.add(articleId);
25235                                    }
25236    
25237                                    if (statuses != null) {
25238                                            qPos.add(statuses);
25239                                    }
25240    
25241                                    count = (Long)q.uniqueResult();
25242    
25243                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25244                                            finderArgs, count);
25245                            }
25246                            catch (Exception e) {
25247                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25248                                            finderArgs);
25249    
25250                                    throw processException(e);
25251                            }
25252                            finally {
25253                                    closeSession(session);
25254                            }
25255                    }
25256    
25257                    return count.intValue();
25258            }
25259    
25260            /**
25261             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25262             *
25263             * @param groupId the group ID
25264             * @param articleId the article ID
25265             * @param status the status
25266             * @return the number of matching journal articles that the user has permission to view
25267             * @throws SystemException if a system exception occurred
25268             */
25269            @Override
25270            public int filterCountByG_A_ST(long groupId, String articleId, int status)
25271                    throws SystemException {
25272                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25273                            return countByG_A_ST(groupId, articleId, status);
25274                    }
25275    
25276                    StringBundler query = new StringBundler(4);
25277    
25278                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25279    
25280                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25281    
25282                    boolean bindArticleId = false;
25283    
25284                    if (articleId == null) {
25285                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25286                    }
25287                    else if (articleId.equals(StringPool.BLANK)) {
25288                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25289                    }
25290                    else {
25291                            bindArticleId = true;
25292    
25293                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25294                    }
25295    
25296                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25297    
25298                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25299                                    JournalArticle.class.getName(),
25300                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25301    
25302                    Session session = null;
25303    
25304                    try {
25305                            session = openSession();
25306    
25307                            SQLQuery q = session.createSQLQuery(sql);
25308    
25309                            q.addScalar(COUNT_COLUMN_NAME,
25310                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
25311    
25312                            QueryPos qPos = QueryPos.getInstance(q);
25313    
25314                            qPos.add(groupId);
25315    
25316                            if (bindArticleId) {
25317                                    qPos.add(articleId);
25318                            }
25319    
25320                            qPos.add(status);
25321    
25322                            Long count = (Long)q.uniqueResult();
25323    
25324                            return count.intValue();
25325                    }
25326                    catch (Exception e) {
25327                            throw processException(e);
25328                    }
25329                    finally {
25330                            closeSession(session);
25331                    }
25332            }
25333    
25334            /**
25335             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25336             *
25337             * @param groupId the group ID
25338             * @param articleId the article ID
25339             * @param statuses the statuses
25340             * @return the number of matching journal articles that the user has permission to view
25341             * @throws SystemException if a system exception occurred
25342             */
25343            @Override
25344            public int filterCountByG_A_ST(long groupId, String articleId,
25345                    int[] statuses) throws SystemException {
25346                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25347                            return countByG_A_ST(groupId, articleId, statuses);
25348                    }
25349    
25350                    StringBundler query = new StringBundler();
25351    
25352                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25353    
25354                    boolean conjunctionable = false;
25355    
25356                    if (conjunctionable) {
25357                            query.append(WHERE_AND);
25358                    }
25359    
25360                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
25361    
25362                    conjunctionable = true;
25363    
25364                    if (conjunctionable) {
25365                            query.append(WHERE_AND);
25366                    }
25367    
25368                    if (articleId == null) {
25369                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
25370                    }
25371                    else if (articleId.equals(StringPool.BLANK)) {
25372                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
25373                    }
25374                    else {
25375                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
25376                    }
25377    
25378                    conjunctionable = true;
25379    
25380                    if ((statuses == null) || (statuses.length > 0)) {
25381                            if (conjunctionable) {
25382                                    query.append(WHERE_AND);
25383                            }
25384    
25385                            query.append(StringPool.OPEN_PARENTHESIS);
25386    
25387                            for (int i = 0; i < statuses.length; i++) {
25388                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
25389    
25390                                    if ((i + 1) < statuses.length) {
25391                                            query.append(WHERE_OR);
25392                                    }
25393                            }
25394    
25395                            query.append(StringPool.CLOSE_PARENTHESIS);
25396    
25397                            conjunctionable = true;
25398                    }
25399    
25400                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25401                                    JournalArticle.class.getName(),
25402                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25403    
25404                    Session session = null;
25405    
25406                    try {
25407                            session = openSession();
25408    
25409                            SQLQuery q = session.createSQLQuery(sql);
25410    
25411                            q.addScalar(COUNT_COLUMN_NAME,
25412                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
25413    
25414                            QueryPos qPos = QueryPos.getInstance(q);
25415    
25416                            qPos.add(groupId);
25417    
25418                            if (articleId != null) {
25419                                    qPos.add(articleId);
25420                            }
25421    
25422                            if (statuses != null) {
25423                                    qPos.add(statuses);
25424                            }
25425    
25426                            Long count = (Long)q.uniqueResult();
25427    
25428                            return count.intValue();
25429                    }
25430                    catch (Exception e) {
25431                            throw processException(e);
25432                    }
25433                    finally {
25434                            closeSession(session);
25435                    }
25436            }
25437    
25438            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
25439            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
25440                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
25441            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
25442            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
25443            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
25444            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
25445                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
25446            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
25447                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
25448            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
25449                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
25450            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
25451            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
25452                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
25453            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25454                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25455                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
25456                            "findByG_UT_ST",
25457                            new String[] {
25458                                    Long.class.getName(), String.class.getName(),
25459                                    Integer.class.getName(),
25460                                    
25461                            Integer.class.getName(), Integer.class.getName(),
25462                                    OrderByComparator.class.getName()
25463                            });
25464            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
25465                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25466                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25467                            JournalArticleImpl.class,
25468                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
25469                            new String[] {
25470                                    Long.class.getName(), String.class.getName(),
25471                                    Integer.class.getName()
25472                            },
25473                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
25474                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
25475                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
25476                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
25477                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
25478            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25479                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
25480                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
25481                            new String[] {
25482                                    Long.class.getName(), String.class.getName(),
25483                                    Integer.class.getName()
25484                            });
25485    
25486            /**
25487             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25488             *
25489             * @param groupId the group ID
25490             * @param urlTitle the url title
25491             * @param status the status
25492             * @return the matching journal articles
25493             * @throws SystemException if a system exception occurred
25494             */
25495            @Override
25496            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
25497                    int status) throws SystemException {
25498                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
25499                            QueryUtil.ALL_POS, null);
25500            }
25501    
25502            /**
25503             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25504             *
25505             * <p>
25506             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25507             * </p>
25508             *
25509             * @param groupId the group ID
25510             * @param urlTitle the url title
25511             * @param status the status
25512             * @param start the lower bound of the range of journal articles
25513             * @param end the upper bound of the range of journal articles (not inclusive)
25514             * @return the range of matching journal articles
25515             * @throws SystemException if a system exception occurred
25516             */
25517            @Override
25518            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
25519                    int status, int start, int end) throws SystemException {
25520                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
25521            }
25522    
25523            /**
25524             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25525             *
25526             * <p>
25527             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25528             * </p>
25529             *
25530             * @param groupId the group ID
25531             * @param urlTitle the url title
25532             * @param status the status
25533             * @param start the lower bound of the range of journal articles
25534             * @param end the upper bound of the range of journal articles (not inclusive)
25535             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25536             * @return the ordered range of matching journal articles
25537             * @throws SystemException if a system exception occurred
25538             */
25539            @Override
25540            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
25541                    int status, int start, int end, OrderByComparator orderByComparator)
25542                    throws SystemException {
25543                    boolean pagination = true;
25544                    FinderPath finderPath = null;
25545                    Object[] finderArgs = null;
25546    
25547                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25548                                    (orderByComparator == null)) {
25549                            pagination = false;
25550                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
25551                            finderArgs = new Object[] { groupId, urlTitle, status };
25552                    }
25553                    else {
25554                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
25555                            finderArgs = new Object[] {
25556                                            groupId, urlTitle, status,
25557                                            
25558                                            start, end, orderByComparator
25559                                    };
25560                    }
25561    
25562                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
25563                                    finderArgs, this);
25564    
25565                    if ((list != null) && !list.isEmpty()) {
25566                            for (JournalArticle journalArticle : list) {
25567                                    if ((groupId != journalArticle.getGroupId()) ||
25568                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
25569                                                    (status != journalArticle.getStatus())) {
25570                                            list = null;
25571    
25572                                            break;
25573                                    }
25574                            }
25575                    }
25576    
25577                    if (list == null) {
25578                            StringBundler query = null;
25579    
25580                            if (orderByComparator != null) {
25581                                    query = new StringBundler(5 +
25582                                                    (orderByComparator.getOrderByFields().length * 3));
25583                            }
25584                            else {
25585                                    query = new StringBundler(5);
25586                            }
25587    
25588                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25589    
25590                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25591    
25592                            boolean bindUrlTitle = false;
25593    
25594                            if (urlTitle == null) {
25595                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25596                            }
25597                            else if (urlTitle.equals(StringPool.BLANK)) {
25598                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25599                            }
25600                            else {
25601                                    bindUrlTitle = true;
25602    
25603                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25604                            }
25605    
25606                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25607    
25608                            if (orderByComparator != null) {
25609                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25610                                            orderByComparator);
25611                            }
25612                            else
25613                             if (pagination) {
25614                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25615                            }
25616    
25617                            String sql = query.toString();
25618    
25619                            Session session = null;
25620    
25621                            try {
25622                                    session = openSession();
25623    
25624                                    Query q = session.createQuery(sql);
25625    
25626                                    QueryPos qPos = QueryPos.getInstance(q);
25627    
25628                                    qPos.add(groupId);
25629    
25630                                    if (bindUrlTitle) {
25631                                            qPos.add(urlTitle);
25632                                    }
25633    
25634                                    qPos.add(status);
25635    
25636                                    if (!pagination) {
25637                                            list = (List<JournalArticle>)QueryUtil.list(q,
25638                                                            getDialect(), start, end, false);
25639    
25640                                            Collections.sort(list);
25641    
25642                                            list = new UnmodifiableList<JournalArticle>(list);
25643                                    }
25644                                    else {
25645                                            list = (List<JournalArticle>)QueryUtil.list(q,
25646                                                            getDialect(), start, end);
25647                                    }
25648    
25649                                    cacheResult(list);
25650    
25651                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
25652                            }
25653                            catch (Exception e) {
25654                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25655    
25656                                    throw processException(e);
25657                            }
25658                            finally {
25659                                    closeSession(session);
25660                            }
25661                    }
25662    
25663                    return list;
25664            }
25665    
25666            /**
25667             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25668             *
25669             * @param groupId the group ID
25670             * @param urlTitle the url title
25671             * @param status the status
25672             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25673             * @return the first matching journal article
25674             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25675             * @throws SystemException if a system exception occurred
25676             */
25677            @Override
25678            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
25679                    int status, OrderByComparator orderByComparator)
25680                    throws NoSuchArticleException, SystemException {
25681                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
25682                                    status, orderByComparator);
25683    
25684                    if (journalArticle != null) {
25685                            return journalArticle;
25686                    }
25687    
25688                    StringBundler msg = new StringBundler(8);
25689    
25690                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25691    
25692                    msg.append("groupId=");
25693                    msg.append(groupId);
25694    
25695                    msg.append(", urlTitle=");
25696                    msg.append(urlTitle);
25697    
25698                    msg.append(", status=");
25699                    msg.append(status);
25700    
25701                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25702    
25703                    throw new NoSuchArticleException(msg.toString());
25704            }
25705    
25706            /**
25707             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25708             *
25709             * @param groupId the group ID
25710             * @param urlTitle the url title
25711             * @param status the status
25712             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25713             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
25714             * @throws SystemException if a system exception occurred
25715             */
25716            @Override
25717            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
25718                    int status, OrderByComparator orderByComparator)
25719                    throws SystemException {
25720                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
25721                                    1, orderByComparator);
25722    
25723                    if (!list.isEmpty()) {
25724                            return list.get(0);
25725                    }
25726    
25727                    return null;
25728            }
25729    
25730            /**
25731             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25732             *
25733             * @param groupId the group ID
25734             * @param urlTitle the url title
25735             * @param status the status
25736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25737             * @return the last matching journal article
25738             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25739             * @throws SystemException if a system exception occurred
25740             */
25741            @Override
25742            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
25743                    int status, OrderByComparator orderByComparator)
25744                    throws NoSuchArticleException, SystemException {
25745                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
25746                                    status, orderByComparator);
25747    
25748                    if (journalArticle != null) {
25749                            return journalArticle;
25750                    }
25751    
25752                    StringBundler msg = new StringBundler(8);
25753    
25754                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25755    
25756                    msg.append("groupId=");
25757                    msg.append(groupId);
25758    
25759                    msg.append(", urlTitle=");
25760                    msg.append(urlTitle);
25761    
25762                    msg.append(", status=");
25763                    msg.append(status);
25764    
25765                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25766    
25767                    throw new NoSuchArticleException(msg.toString());
25768            }
25769    
25770            /**
25771             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25772             *
25773             * @param groupId the group ID
25774             * @param urlTitle the url title
25775             * @param status the status
25776             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25777             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
25778             * @throws SystemException if a system exception occurred
25779             */
25780            @Override
25781            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
25782                    int status, OrderByComparator orderByComparator)
25783                    throws SystemException {
25784                    int count = countByG_UT_ST(groupId, urlTitle, status);
25785    
25786                    if (count == 0) {
25787                            return null;
25788                    }
25789    
25790                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
25791                                    count - 1, count, orderByComparator);
25792    
25793                    if (!list.isEmpty()) {
25794                            return list.get(0);
25795                    }
25796    
25797                    return null;
25798            }
25799    
25800            /**
25801             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25802             *
25803             * @param id the primary key of the current journal article
25804             * @param groupId the group ID
25805             * @param urlTitle the url title
25806             * @param status the status
25807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25808             * @return the previous, current, and next journal article
25809             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25810             * @throws SystemException if a system exception occurred
25811             */
25812            @Override
25813            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
25814                    String urlTitle, int status, OrderByComparator orderByComparator)
25815                    throws NoSuchArticleException, SystemException {
25816                    JournalArticle journalArticle = findByPrimaryKey(id);
25817    
25818                    Session session = null;
25819    
25820                    try {
25821                            session = openSession();
25822    
25823                            JournalArticle[] array = new JournalArticleImpl[3];
25824    
25825                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
25826                                            groupId, urlTitle, status, orderByComparator, true);
25827    
25828                            array[1] = journalArticle;
25829    
25830                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
25831                                            groupId, urlTitle, status, orderByComparator, false);
25832    
25833                            return array;
25834                    }
25835                    catch (Exception e) {
25836                            throw processException(e);
25837                    }
25838                    finally {
25839                            closeSession(session);
25840                    }
25841            }
25842    
25843            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
25844                    JournalArticle journalArticle, long groupId, String urlTitle,
25845                    int status, OrderByComparator orderByComparator, boolean previous) {
25846                    StringBundler query = null;
25847    
25848                    if (orderByComparator != null) {
25849                            query = new StringBundler(6 +
25850                                            (orderByComparator.getOrderByFields().length * 6));
25851                    }
25852                    else {
25853                            query = new StringBundler(3);
25854                    }
25855    
25856                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25857    
25858                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25859    
25860                    boolean bindUrlTitle = false;
25861    
25862                    if (urlTitle == null) {
25863                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25864                    }
25865                    else if (urlTitle.equals(StringPool.BLANK)) {
25866                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25867                    }
25868                    else {
25869                            bindUrlTitle = true;
25870    
25871                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25872                    }
25873    
25874                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25875    
25876                    if (orderByComparator != null) {
25877                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25878    
25879                            if (orderByConditionFields.length > 0) {
25880                                    query.append(WHERE_AND);
25881                            }
25882    
25883                            for (int i = 0; i < orderByConditionFields.length; i++) {
25884                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25885                                    query.append(orderByConditionFields[i]);
25886    
25887                                    if ((i + 1) < orderByConditionFields.length) {
25888                                            if (orderByComparator.isAscending() ^ previous) {
25889                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25890                                            }
25891                                            else {
25892                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25893                                            }
25894                                    }
25895                                    else {
25896                                            if (orderByComparator.isAscending() ^ previous) {
25897                                                    query.append(WHERE_GREATER_THAN);
25898                                            }
25899                                            else {
25900                                                    query.append(WHERE_LESSER_THAN);
25901                                            }
25902                                    }
25903                            }
25904    
25905                            query.append(ORDER_BY_CLAUSE);
25906    
25907                            String[] orderByFields = orderByComparator.getOrderByFields();
25908    
25909                            for (int i = 0; i < orderByFields.length; i++) {
25910                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25911                                    query.append(orderByFields[i]);
25912    
25913                                    if ((i + 1) < orderByFields.length) {
25914                                            if (orderByComparator.isAscending() ^ previous) {
25915                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25916                                            }
25917                                            else {
25918                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25919                                            }
25920                                    }
25921                                    else {
25922                                            if (orderByComparator.isAscending() ^ previous) {
25923                                                    query.append(ORDER_BY_ASC);
25924                                            }
25925                                            else {
25926                                                    query.append(ORDER_BY_DESC);
25927                                            }
25928                                    }
25929                            }
25930                    }
25931                    else {
25932                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25933                    }
25934    
25935                    String sql = query.toString();
25936    
25937                    Query q = session.createQuery(sql);
25938    
25939                    q.setFirstResult(0);
25940                    q.setMaxResults(2);
25941    
25942                    QueryPos qPos = QueryPos.getInstance(q);
25943    
25944                    qPos.add(groupId);
25945    
25946                    if (bindUrlTitle) {
25947                            qPos.add(urlTitle);
25948                    }
25949    
25950                    qPos.add(status);
25951    
25952                    if (orderByComparator != null) {
25953                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25954    
25955                            for (Object value : values) {
25956                                    qPos.add(value);
25957                            }
25958                    }
25959    
25960                    List<JournalArticle> list = q.list();
25961    
25962                    if (list.size() == 2) {
25963                            return list.get(1);
25964                    }
25965                    else {
25966                            return null;
25967                    }
25968            }
25969    
25970            /**
25971             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25972             *
25973             * @param groupId the group ID
25974             * @param urlTitle the url title
25975             * @param status the status
25976             * @return the matching journal articles that the user has permission to view
25977             * @throws SystemException if a system exception occurred
25978             */
25979            @Override
25980            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
25981                    String urlTitle, int status) throws SystemException {
25982                    return filterFindByG_UT_ST(groupId, urlTitle, status,
25983                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25984            }
25985    
25986            /**
25987             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25988             *
25989             * <p>
25990             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25991             * </p>
25992             *
25993             * @param groupId the group ID
25994             * @param urlTitle the url title
25995             * @param status the status
25996             * @param start the lower bound of the range of journal articles
25997             * @param end the upper bound of the range of journal articles (not inclusive)
25998             * @return the range of matching journal articles that the user has permission to view
25999             * @throws SystemException if a system exception occurred
26000             */
26001            @Override
26002            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
26003                    String urlTitle, int status, int start, int end)
26004                    throws SystemException {
26005                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
26006            }
26007    
26008            /**
26009             * 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;.
26010             *
26011             * <p>
26012             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26013             * </p>
26014             *
26015             * @param groupId the group ID
26016             * @param urlTitle the url title
26017             * @param status the status
26018             * @param start the lower bound of the range of journal articles
26019             * @param end the upper bound of the range of journal articles (not inclusive)
26020             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26021             * @return the ordered range of matching journal articles that the user has permission to view
26022             * @throws SystemException if a system exception occurred
26023             */
26024            @Override
26025            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
26026                    String urlTitle, int status, int start, int end,
26027                    OrderByComparator orderByComparator) throws SystemException {
26028                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26029                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
26030                                    orderByComparator);
26031                    }
26032    
26033                    StringBundler query = null;
26034    
26035                    if (orderByComparator != null) {
26036                            query = new StringBundler(5 +
26037                                            (orderByComparator.getOrderByFields().length * 3));
26038                    }
26039                    else {
26040                            query = new StringBundler(5);
26041                    }
26042    
26043                    if (getDB().isSupportsInlineDistinct()) {
26044                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26045                    }
26046                    else {
26047                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26048                    }
26049    
26050                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
26051    
26052                    boolean bindUrlTitle = false;
26053    
26054                    if (urlTitle == null) {
26055                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
26056                    }
26057                    else if (urlTitle.equals(StringPool.BLANK)) {
26058                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
26059                    }
26060                    else {
26061                            bindUrlTitle = true;
26062    
26063                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
26064                    }
26065    
26066                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
26067    
26068                    if (!getDB().isSupportsInlineDistinct()) {
26069                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26070                    }
26071    
26072                    if (orderByComparator != null) {
26073                            if (getDB().isSupportsInlineDistinct()) {
26074                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26075                                            orderByComparator, true);
26076                            }
26077                            else {
26078                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
26079                                            orderByComparator, true);
26080                            }
26081                    }
26082                    else {
26083                            if (getDB().isSupportsInlineDistinct()) {
26084                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26085                            }
26086                            else {
26087                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26088                            }
26089                    }
26090    
26091                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26092                                    JournalArticle.class.getName(),
26093                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26094    
26095                    Session session = null;
26096    
26097                    try {
26098                            session = openSession();
26099    
26100                            SQLQuery q = session.createSQLQuery(sql);
26101    
26102                            if (getDB().isSupportsInlineDistinct()) {
26103                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26104                            }
26105                            else {
26106                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26107                            }
26108    
26109                            QueryPos qPos = QueryPos.getInstance(q);
26110    
26111                            qPos.add(groupId);
26112    
26113                            if (bindUrlTitle) {
26114                                    qPos.add(urlTitle);
26115                            }
26116    
26117                            qPos.add(status);
26118    
26119                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
26120                                    end);
26121                    }
26122                    catch (Exception e) {
26123                            throw processException(e);
26124                    }
26125                    finally {
26126                            closeSession(session);
26127                    }
26128            }
26129    
26130            /**
26131             * 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;.
26132             *
26133             * @param id the primary key of the current journal article
26134             * @param groupId the group ID
26135             * @param urlTitle the url title
26136             * @param status the status
26137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26138             * @return the previous, current, and next journal article
26139             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26140             * @throws SystemException if a system exception occurred
26141             */
26142            @Override
26143            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
26144                    long groupId, String urlTitle, int status,
26145                    OrderByComparator orderByComparator)
26146                    throws NoSuchArticleException, SystemException {
26147                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26148                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
26149                                    orderByComparator);
26150                    }
26151    
26152                    JournalArticle journalArticle = findByPrimaryKey(id);
26153    
26154                    Session session = null;
26155    
26156                    try {
26157                            session = openSession();
26158    
26159                            JournalArticle[] array = new JournalArticleImpl[3];
26160    
26161                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
26162                                            groupId, urlTitle, status, orderByComparator, true);
26163    
26164                            array[1] = journalArticle;
26165    
26166                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
26167                                            groupId, urlTitle, status, orderByComparator, false);
26168    
26169                            return array;
26170                    }
26171                    catch (Exception e) {
26172                            throw processException(e);
26173                    }
26174                    finally {
26175                            closeSession(session);
26176                    }
26177            }
26178    
26179            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
26180                    JournalArticle journalArticle, long groupId, String urlTitle,
26181                    int status, OrderByComparator orderByComparator, boolean previous) {
26182                    StringBundler query = null;
26183    
26184                    if (orderByComparator != null) {
26185                            query = new StringBundler(6 +
26186                                            (orderByComparator.getOrderByFields().length * 6));
26187                    }
26188                    else {
26189                            query = new StringBundler(3);
26190                    }
26191    
26192                    if (getDB().isSupportsInlineDistinct()) {
26193                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26194                    }
26195                    else {
26196                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26197                    }
26198    
26199                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
26200    
26201                    boolean bindUrlTitle = false;
26202    
26203                    if (urlTitle == null) {
26204                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
26205                    }
26206                    else if (urlTitle.equals(StringPool.BLANK)) {
26207                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
26208                    }
26209                    else {
26210                            bindUrlTitle = true;
26211    
26212                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
26213                    }
26214    
26215                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
26216    
26217                    if (!getDB().isSupportsInlineDistinct()) {
26218                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26219                    }
26220    
26221                    if (orderByComparator != null) {
26222                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26223    
26224                            if (orderByConditionFields.length > 0) {
26225                                    query.append(WHERE_AND);
26226                            }
26227    
26228                            for (int i = 0; i < orderByConditionFields.length; i++) {
26229                                    if (getDB().isSupportsInlineDistinct()) {
26230                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26231                                    }
26232                                    else {
26233                                            query.append(_ORDER_BY_ENTITY_TABLE);
26234                                    }
26235    
26236                                    query.append(orderByConditionFields[i]);
26237    
26238                                    if ((i + 1) < orderByConditionFields.length) {
26239                                            if (orderByComparator.isAscending() ^ previous) {
26240                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26241                                            }
26242                                            else {
26243                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26244                                            }
26245                                    }
26246                                    else {
26247                                            if (orderByComparator.isAscending() ^ previous) {
26248                                                    query.append(WHERE_GREATER_THAN);
26249                                            }
26250                                            else {
26251                                                    query.append(WHERE_LESSER_THAN);
26252                                            }
26253                                    }
26254                            }
26255    
26256                            query.append(ORDER_BY_CLAUSE);
26257    
26258                            String[] orderByFields = orderByComparator.getOrderByFields();
26259    
26260                            for (int i = 0; i < orderByFields.length; i++) {
26261                                    if (getDB().isSupportsInlineDistinct()) {
26262                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26263                                    }
26264                                    else {
26265                                            query.append(_ORDER_BY_ENTITY_TABLE);
26266                                    }
26267    
26268                                    query.append(orderByFields[i]);
26269    
26270                                    if ((i + 1) < orderByFields.length) {
26271                                            if (orderByComparator.isAscending() ^ previous) {
26272                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26273                                            }
26274                                            else {
26275                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26276                                            }
26277                                    }
26278                                    else {
26279                                            if (orderByComparator.isAscending() ^ previous) {
26280                                                    query.append(ORDER_BY_ASC);
26281                                            }
26282                                            else {
26283                                                    query.append(ORDER_BY_DESC);
26284                                            }
26285                                    }
26286                            }
26287                    }
26288                    else {
26289                            if (getDB().isSupportsInlineDistinct()) {
26290                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26291                            }
26292                            else {
26293                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26294                            }
26295                    }
26296    
26297                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26298                                    JournalArticle.class.getName(),
26299                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26300    
26301                    SQLQuery q = session.createSQLQuery(sql);
26302    
26303                    q.setFirstResult(0);
26304                    q.setMaxResults(2);
26305    
26306                    if (getDB().isSupportsInlineDistinct()) {
26307                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26308                    }
26309                    else {
26310                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26311                    }
26312    
26313                    QueryPos qPos = QueryPos.getInstance(q);
26314    
26315                    qPos.add(groupId);
26316    
26317                    if (bindUrlTitle) {
26318                            qPos.add(urlTitle);
26319                    }
26320    
26321                    qPos.add(status);
26322    
26323                    if (orderByComparator != null) {
26324                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26325    
26326                            for (Object value : values) {
26327                                    qPos.add(value);
26328                            }
26329                    }
26330    
26331                    List<JournalArticle> list = q.list();
26332    
26333                    if (list.size() == 2) {
26334                            return list.get(1);
26335                    }
26336                    else {
26337                            return null;
26338                    }
26339            }
26340    
26341            /**
26342             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
26343             *
26344             * @param groupId the group ID
26345             * @param urlTitle the url title
26346             * @param status the status
26347             * @throws SystemException if a system exception occurred
26348             */
26349            @Override
26350            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
26351                    throws SystemException {
26352                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
26353                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26354                            remove(journalArticle);
26355                    }
26356            }
26357    
26358            /**
26359             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
26360             *
26361             * @param groupId the group ID
26362             * @param urlTitle the url title
26363             * @param status the status
26364             * @return the number of matching journal articles
26365             * @throws SystemException if a system exception occurred
26366             */
26367            @Override
26368            public int countByG_UT_ST(long groupId, String urlTitle, int status)
26369                    throws SystemException {
26370                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
26371    
26372                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
26373    
26374                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26375                                    this);
26376    
26377                    if (count == null) {
26378                            StringBundler query = new StringBundler(4);
26379    
26380                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26381    
26382                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
26383    
26384                            boolean bindUrlTitle = false;
26385    
26386                            if (urlTitle == null) {
26387                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
26388                            }
26389                            else if (urlTitle.equals(StringPool.BLANK)) {
26390                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
26391                            }
26392                            else {
26393                                    bindUrlTitle = true;
26394    
26395                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
26396                            }
26397    
26398                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
26399    
26400                            String sql = query.toString();
26401    
26402                            Session session = null;
26403    
26404                            try {
26405                                    session = openSession();
26406    
26407                                    Query q = session.createQuery(sql);
26408    
26409                                    QueryPos qPos = QueryPos.getInstance(q);
26410    
26411                                    qPos.add(groupId);
26412    
26413                                    if (bindUrlTitle) {
26414                                            qPos.add(urlTitle);
26415                                    }
26416    
26417                                    qPos.add(status);
26418    
26419                                    count = (Long)q.uniqueResult();
26420    
26421                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26422                            }
26423                            catch (Exception e) {
26424                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26425    
26426                                    throw processException(e);
26427                            }
26428                            finally {
26429                                    closeSession(session);
26430                            }
26431                    }
26432    
26433                    return count.intValue();
26434            }
26435    
26436            /**
26437             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
26438             *
26439             * @param groupId the group ID
26440             * @param urlTitle the url title
26441             * @param status the status
26442             * @return the number of matching journal articles that the user has permission to view
26443             * @throws SystemException if a system exception occurred
26444             */
26445            @Override
26446            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
26447                    throws SystemException {
26448                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26449                            return countByG_UT_ST(groupId, urlTitle, status);
26450                    }
26451    
26452                    StringBundler query = new StringBundler(4);
26453    
26454                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26455    
26456                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
26457    
26458                    boolean bindUrlTitle = false;
26459    
26460                    if (urlTitle == null) {
26461                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
26462                    }
26463                    else if (urlTitle.equals(StringPool.BLANK)) {
26464                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
26465                    }
26466                    else {
26467                            bindUrlTitle = true;
26468    
26469                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
26470                    }
26471    
26472                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
26473    
26474                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26475                                    JournalArticle.class.getName(),
26476                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26477    
26478                    Session session = null;
26479    
26480                    try {
26481                            session = openSession();
26482    
26483                            SQLQuery q = session.createSQLQuery(sql);
26484    
26485                            q.addScalar(COUNT_COLUMN_NAME,
26486                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26487    
26488                            QueryPos qPos = QueryPos.getInstance(q);
26489    
26490                            qPos.add(groupId);
26491    
26492                            if (bindUrlTitle) {
26493                                    qPos.add(urlTitle);
26494                            }
26495    
26496                            qPos.add(status);
26497    
26498                            Long count = (Long)q.uniqueResult();
26499    
26500                            return count.intValue();
26501                    }
26502                    catch (Exception e) {
26503                            throw processException(e);
26504                    }
26505                    finally {
26506                            closeSession(session);
26507                    }
26508            }
26509    
26510            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
26511            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
26512            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
26513            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
26514            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
26515            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26516                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26517                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
26518                            "findByC_V_ST",
26519                            new String[] {
26520                                    Long.class.getName(), Double.class.getName(),
26521                                    Integer.class.getName(),
26522                                    
26523                            Integer.class.getName(), Integer.class.getName(),
26524                                    OrderByComparator.class.getName()
26525                            });
26526            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
26527                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26528                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26529                            JournalArticleImpl.class,
26530                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
26531                            new String[] {
26532                                    Long.class.getName(), Double.class.getName(),
26533                                    Integer.class.getName()
26534                            },
26535                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
26536                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
26537                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
26538                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
26539            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26540                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26541                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
26542                            new String[] {
26543                                    Long.class.getName(), Double.class.getName(),
26544                                    Integer.class.getName()
26545                            });
26546    
26547            /**
26548             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
26549             *
26550             * @param companyId the company ID
26551             * @param version the version
26552             * @param status the status
26553             * @return the matching journal articles
26554             * @throws SystemException if a system exception occurred
26555             */
26556            @Override
26557            public List<JournalArticle> findByC_V_ST(long companyId, double version,
26558                    int status) throws SystemException {
26559                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
26560                            QueryUtil.ALL_POS, null);
26561            }
26562    
26563            /**
26564             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
26565             *
26566             * <p>
26567             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26568             * </p>
26569             *
26570             * @param companyId the company ID
26571             * @param version the version
26572             * @param status the status
26573             * @param start the lower bound of the range of journal articles
26574             * @param end the upper bound of the range of journal articles (not inclusive)
26575             * @return the range of matching journal articles
26576             * @throws SystemException if a system exception occurred
26577             */
26578            @Override
26579            public List<JournalArticle> findByC_V_ST(long companyId, double version,
26580                    int status, int start, int end) throws SystemException {
26581                    return findByC_V_ST(companyId, version, status, start, end, null);
26582            }
26583    
26584            /**
26585             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
26586             *
26587             * <p>
26588             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26589             * </p>
26590             *
26591             * @param companyId the company ID
26592             * @param version the version
26593             * @param status the status
26594             * @param start the lower bound of the range of journal articles
26595             * @param end the upper bound of the range of journal articles (not inclusive)
26596             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26597             * @return the ordered range of matching journal articles
26598             * @throws SystemException if a system exception occurred
26599             */
26600            @Override
26601            public List<JournalArticle> findByC_V_ST(long companyId, double version,
26602                    int status, int start, int end, OrderByComparator orderByComparator)
26603                    throws SystemException {
26604                    boolean pagination = true;
26605                    FinderPath finderPath = null;
26606                    Object[] finderArgs = null;
26607    
26608                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
26609                                    (orderByComparator == null)) {
26610                            pagination = false;
26611                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
26612                            finderArgs = new Object[] { companyId, version, status };
26613                    }
26614                    else {
26615                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
26616                            finderArgs = new Object[] {
26617                                            companyId, version, status,
26618                                            
26619                                            start, end, orderByComparator
26620                                    };
26621                    }
26622    
26623                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26624                                    finderArgs, this);
26625    
26626                    if ((list != null) && !list.isEmpty()) {
26627                            for (JournalArticle journalArticle : list) {
26628                                    if ((companyId != journalArticle.getCompanyId()) ||
26629                                                    (version != journalArticle.getVersion()) ||
26630                                                    (status != journalArticle.getStatus())) {
26631                                            list = null;
26632    
26633                                            break;
26634                                    }
26635                            }
26636                    }
26637    
26638                    if (list == null) {
26639                            StringBundler query = null;
26640    
26641                            if (orderByComparator != null) {
26642                                    query = new StringBundler(5 +
26643                                                    (orderByComparator.getOrderByFields().length * 3));
26644                            }
26645                            else {
26646                                    query = new StringBundler(5);
26647                            }
26648    
26649                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26650    
26651                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
26652    
26653                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
26654    
26655                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
26656    
26657                            if (orderByComparator != null) {
26658                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26659                                            orderByComparator);
26660                            }
26661                            else
26662                             if (pagination) {
26663                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26664                            }
26665    
26666                            String sql = query.toString();
26667    
26668                            Session session = null;
26669    
26670                            try {
26671                                    session = openSession();
26672    
26673                                    Query q = session.createQuery(sql);
26674    
26675                                    QueryPos qPos = QueryPos.getInstance(q);
26676    
26677                                    qPos.add(companyId);
26678    
26679                                    qPos.add(version);
26680    
26681                                    qPos.add(status);
26682    
26683                                    if (!pagination) {
26684                                            list = (List<JournalArticle>)QueryUtil.list(q,
26685                                                            getDialect(), start, end, false);
26686    
26687                                            Collections.sort(list);
26688    
26689                                            list = new UnmodifiableList<JournalArticle>(list);
26690                                    }
26691                                    else {
26692                                            list = (List<JournalArticle>)QueryUtil.list(q,
26693                                                            getDialect(), start, end);
26694                                    }
26695    
26696                                    cacheResult(list);
26697    
26698                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
26699                            }
26700                            catch (Exception e) {
26701                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26702    
26703                                    throw processException(e);
26704                            }
26705                            finally {
26706                                    closeSession(session);
26707                            }
26708                    }
26709    
26710                    return list;
26711            }
26712    
26713            /**
26714             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26715             *
26716             * @param companyId the company ID
26717             * @param version the version
26718             * @param status the status
26719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26720             * @return the first matching journal article
26721             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26722             * @throws SystemException if a system exception occurred
26723             */
26724            @Override
26725            public JournalArticle findByC_V_ST_First(long companyId, double version,
26726                    int status, OrderByComparator orderByComparator)
26727                    throws NoSuchArticleException, SystemException {
26728                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
26729                                    status, orderByComparator);
26730    
26731                    if (journalArticle != null) {
26732                            return journalArticle;
26733                    }
26734    
26735                    StringBundler msg = new StringBundler(8);
26736    
26737                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26738    
26739                    msg.append("companyId=");
26740                    msg.append(companyId);
26741    
26742                    msg.append(", version=");
26743                    msg.append(version);
26744    
26745                    msg.append(", status=");
26746                    msg.append(status);
26747    
26748                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26749    
26750                    throw new NoSuchArticleException(msg.toString());
26751            }
26752    
26753            /**
26754             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26755             *
26756             * @param companyId the company ID
26757             * @param version the version
26758             * @param status the status
26759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26760             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
26761             * @throws SystemException if a system exception occurred
26762             */
26763            @Override
26764            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
26765                    int status, OrderByComparator orderByComparator)
26766                    throws SystemException {
26767                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
26768                                    1, orderByComparator);
26769    
26770                    if (!list.isEmpty()) {
26771                            return list.get(0);
26772                    }
26773    
26774                    return null;
26775            }
26776    
26777            /**
26778             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26779             *
26780             * @param companyId the company ID
26781             * @param version the version
26782             * @param status the status
26783             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26784             * @return the last matching journal article
26785             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26786             * @throws SystemException if a system exception occurred
26787             */
26788            @Override
26789            public JournalArticle findByC_V_ST_Last(long companyId, double version,
26790                    int status, OrderByComparator orderByComparator)
26791                    throws NoSuchArticleException, SystemException {
26792                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
26793                                    status, orderByComparator);
26794    
26795                    if (journalArticle != null) {
26796                            return journalArticle;
26797                    }
26798    
26799                    StringBundler msg = new StringBundler(8);
26800    
26801                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26802    
26803                    msg.append("companyId=");
26804                    msg.append(companyId);
26805    
26806                    msg.append(", version=");
26807                    msg.append(version);
26808    
26809                    msg.append(", status=");
26810                    msg.append(status);
26811    
26812                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26813    
26814                    throw new NoSuchArticleException(msg.toString());
26815            }
26816    
26817            /**
26818             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26819             *
26820             * @param companyId the company ID
26821             * @param version the version
26822             * @param status the status
26823             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26824             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
26825             * @throws SystemException if a system exception occurred
26826             */
26827            @Override
26828            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
26829                    int status, OrderByComparator orderByComparator)
26830                    throws SystemException {
26831                    int count = countByC_V_ST(companyId, version, status);
26832    
26833                    if (count == 0) {
26834                            return null;
26835                    }
26836    
26837                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
26838                                    count - 1, count, orderByComparator);
26839    
26840                    if (!list.isEmpty()) {
26841                            return list.get(0);
26842                    }
26843    
26844                    return null;
26845            }
26846    
26847            /**
26848             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26849             *
26850             * @param id the primary key of the current journal article
26851             * @param companyId the company ID
26852             * @param version the version
26853             * @param status the status
26854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26855             * @return the previous, current, and next journal article
26856             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26857             * @throws SystemException if a system exception occurred
26858             */
26859            @Override
26860            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
26861                    double version, int status, OrderByComparator orderByComparator)
26862                    throws NoSuchArticleException, SystemException {
26863                    JournalArticle journalArticle = findByPrimaryKey(id);
26864    
26865                    Session session = null;
26866    
26867                    try {
26868                            session = openSession();
26869    
26870                            JournalArticle[] array = new JournalArticleImpl[3];
26871    
26872                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
26873                                            companyId, version, status, orderByComparator, true);
26874    
26875                            array[1] = journalArticle;
26876    
26877                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
26878                                            companyId, version, status, orderByComparator, false);
26879    
26880                            return array;
26881                    }
26882                    catch (Exception e) {
26883                            throw processException(e);
26884                    }
26885                    finally {
26886                            closeSession(session);
26887                    }
26888            }
26889    
26890            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
26891                    JournalArticle journalArticle, long companyId, double version,
26892                    int status, OrderByComparator orderByComparator, boolean previous) {
26893                    StringBundler query = null;
26894    
26895                    if (orderByComparator != null) {
26896                            query = new StringBundler(6 +
26897                                            (orderByComparator.getOrderByFields().length * 6));
26898                    }
26899                    else {
26900                            query = new StringBundler(3);
26901                    }
26902    
26903                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26904    
26905                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
26906    
26907                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
26908    
26909                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
26910    
26911                    if (orderByComparator != null) {
26912                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26913    
26914                            if (orderByConditionFields.length > 0) {
26915                                    query.append(WHERE_AND);
26916                            }
26917    
26918                            for (int i = 0; i < orderByConditionFields.length; i++) {
26919                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26920                                    query.append(orderByConditionFields[i]);
26921    
26922                                    if ((i + 1) < orderByConditionFields.length) {
26923                                            if (orderByComparator.isAscending() ^ previous) {
26924                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26925                                            }
26926                                            else {
26927                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26928                                            }
26929                                    }
26930                                    else {
26931                                            if (orderByComparator.isAscending() ^ previous) {
26932                                                    query.append(WHERE_GREATER_THAN);
26933                                            }
26934                                            else {
26935                                                    query.append(WHERE_LESSER_THAN);
26936                                            }
26937                                    }
26938                            }
26939    
26940                            query.append(ORDER_BY_CLAUSE);
26941    
26942                            String[] orderByFields = orderByComparator.getOrderByFields();
26943    
26944                            for (int i = 0; i < orderByFields.length; i++) {
26945                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26946                                    query.append(orderByFields[i]);
26947    
26948                                    if ((i + 1) < orderByFields.length) {
26949                                            if (orderByComparator.isAscending() ^ previous) {
26950                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26951                                            }
26952                                            else {
26953                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26954                                            }
26955                                    }
26956                                    else {
26957                                            if (orderByComparator.isAscending() ^ previous) {
26958                                                    query.append(ORDER_BY_ASC);
26959                                            }
26960                                            else {
26961                                                    query.append(ORDER_BY_DESC);
26962                                            }
26963                                    }
26964                            }
26965                    }
26966                    else {
26967                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26968                    }
26969    
26970                    String sql = query.toString();
26971    
26972                    Query q = session.createQuery(sql);
26973    
26974                    q.setFirstResult(0);
26975                    q.setMaxResults(2);
26976    
26977                    QueryPos qPos = QueryPos.getInstance(q);
26978    
26979                    qPos.add(companyId);
26980    
26981                    qPos.add(version);
26982    
26983                    qPos.add(status);
26984    
26985                    if (orderByComparator != null) {
26986                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26987    
26988                            for (Object value : values) {
26989                                    qPos.add(value);
26990                            }
26991                    }
26992    
26993                    List<JournalArticle> list = q.list();
26994    
26995                    if (list.size() == 2) {
26996                            return list.get(1);
26997                    }
26998                    else {
26999                            return null;
27000                    }
27001            }
27002    
27003            /**
27004             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
27005             *
27006             * @param companyId the company ID
27007             * @param version the version
27008             * @param status the status
27009             * @throws SystemException if a system exception occurred
27010             */
27011            @Override
27012            public void removeByC_V_ST(long companyId, double version, int status)
27013                    throws SystemException {
27014                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
27015                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
27016                            remove(journalArticle);
27017                    }
27018            }
27019    
27020            /**
27021             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
27022             *
27023             * @param companyId the company ID
27024             * @param version the version
27025             * @param status the status
27026             * @return the number of matching journal articles
27027             * @throws SystemException if a system exception occurred
27028             */
27029            @Override
27030            public int countByC_V_ST(long companyId, double version, int status)
27031                    throws SystemException {
27032                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
27033    
27034                    Object[] finderArgs = new Object[] { companyId, version, status };
27035    
27036                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
27037                                    this);
27038    
27039                    if (count == null) {
27040                            StringBundler query = new StringBundler(4);
27041    
27042                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
27043    
27044                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
27045    
27046                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
27047    
27048                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
27049    
27050                            String sql = query.toString();
27051    
27052                            Session session = null;
27053    
27054                            try {
27055                                    session = openSession();
27056    
27057                                    Query q = session.createQuery(sql);
27058    
27059                                    QueryPos qPos = QueryPos.getInstance(q);
27060    
27061                                    qPos.add(companyId);
27062    
27063                                    qPos.add(version);
27064    
27065                                    qPos.add(status);
27066    
27067                                    count = (Long)q.uniqueResult();
27068    
27069                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
27070                            }
27071                            catch (Exception e) {
27072                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27073    
27074                                    throw processException(e);
27075                            }
27076                            finally {
27077                                    closeSession(session);
27078                            }
27079                    }
27080    
27081                    return count.intValue();
27082            }
27083    
27084            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
27085            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
27086            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
27087    
27088            public JournalArticlePersistenceImpl() {
27089                    setModelClass(JournalArticle.class);
27090            }
27091    
27092            /**
27093             * Caches the journal article in the entity cache if it is enabled.
27094             *
27095             * @param journalArticle the journal article
27096             */
27097            @Override
27098            public void cacheResult(JournalArticle journalArticle) {
27099                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27100                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
27101                            journalArticle);
27102    
27103                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
27104                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
27105                            journalArticle);
27106    
27107                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
27108                            new Object[] {
27109                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
27110                                    journalArticle.getStructureId()
27111                            }, journalArticle);
27112    
27113                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
27114                            new Object[] {
27115                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
27116                                    journalArticle.getVersion()
27117                            }, journalArticle);
27118    
27119                    journalArticle.resetOriginalValues();
27120            }
27121    
27122            /**
27123             * Caches the journal articles in the entity cache if it is enabled.
27124             *
27125             * @param journalArticles the journal articles
27126             */
27127            @Override
27128            public void cacheResult(List<JournalArticle> journalArticles) {
27129                    for (JournalArticle journalArticle : journalArticles) {
27130                            if (EntityCacheUtil.getResult(
27131                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27132                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
27133                                    cacheResult(journalArticle);
27134                            }
27135                            else {
27136                                    journalArticle.resetOriginalValues();
27137                            }
27138                    }
27139            }
27140    
27141            /**
27142             * Clears the cache for all journal articles.
27143             *
27144             * <p>
27145             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
27146             * </p>
27147             */
27148            @Override
27149            public void clearCache() {
27150                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
27151                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
27152                    }
27153    
27154                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
27155    
27156                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
27157                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
27158                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
27159            }
27160    
27161            /**
27162             * Clears the cache for the journal article.
27163             *
27164             * <p>
27165             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
27166             * </p>
27167             */
27168            @Override
27169            public void clearCache(JournalArticle journalArticle) {
27170                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27171                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
27172    
27173                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
27174                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
27175    
27176                    clearUniqueFindersCache(journalArticle);
27177            }
27178    
27179            @Override
27180            public void clearCache(List<JournalArticle> journalArticles) {
27181                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
27182                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
27183    
27184                    for (JournalArticle journalArticle : journalArticles) {
27185                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27186                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
27187    
27188                            clearUniqueFindersCache(journalArticle);
27189                    }
27190            }
27191    
27192            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
27193                    if (journalArticle.isNew()) {
27194                            Object[] args = new Object[] {
27195                                            journalArticle.getUuid(), journalArticle.getGroupId()
27196                                    };
27197    
27198                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
27199                                    Long.valueOf(1));
27200                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
27201                                    journalArticle);
27202    
27203                            args = new Object[] {
27204                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
27205                                            journalArticle.getStructureId()
27206                                    };
27207    
27208                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
27209                                    Long.valueOf(1));
27210                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
27211                                    journalArticle);
27212    
27213                            args = new Object[] {
27214                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
27215                                            journalArticle.getVersion()
27216                                    };
27217    
27218                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
27219                                    Long.valueOf(1));
27220                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
27221                                    journalArticle);
27222                    }
27223                    else {
27224                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
27225    
27226                            if ((journalArticleModelImpl.getColumnBitmask() &
27227                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
27228                                    Object[] args = new Object[] {
27229                                                    journalArticle.getUuid(), journalArticle.getGroupId()
27230                                            };
27231    
27232                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
27233                                            Long.valueOf(1));
27234                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
27235                                            journalArticle);
27236                            }
27237    
27238                            if ((journalArticleModelImpl.getColumnBitmask() &
27239                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
27240                                    Object[] args = new Object[] {
27241                                                    journalArticle.getGroupId(),
27242                                                    journalArticle.getClassNameId(),
27243                                                    journalArticle.getStructureId()
27244                                            };
27245    
27246                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
27247                                            Long.valueOf(1));
27248                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
27249                                            journalArticle);
27250                            }
27251    
27252                            if ((journalArticleModelImpl.getColumnBitmask() &
27253                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
27254                                    Object[] args = new Object[] {
27255                                                    journalArticle.getGroupId(),
27256                                                    journalArticle.getArticleId(),
27257                                                    journalArticle.getVersion()
27258                                            };
27259    
27260                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
27261                                            Long.valueOf(1));
27262                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
27263                                            journalArticle);
27264                            }
27265                    }
27266            }
27267    
27268            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
27269                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
27270    
27271                    Object[] args = new Object[] {
27272                                    journalArticle.getUuid(), journalArticle.getGroupId()
27273                            };
27274    
27275                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
27276                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
27277    
27278                    if ((journalArticleModelImpl.getColumnBitmask() &
27279                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
27280                            args = new Object[] {
27281                                            journalArticleModelImpl.getOriginalUuid(),
27282                                            journalArticleModelImpl.getOriginalGroupId()
27283                                    };
27284    
27285                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
27286                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
27287                    }
27288    
27289                    args = new Object[] {
27290                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
27291                                    journalArticle.getStructureId()
27292                            };
27293    
27294                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
27295                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
27296    
27297                    if ((journalArticleModelImpl.getColumnBitmask() &
27298                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
27299                            args = new Object[] {
27300                                            journalArticleModelImpl.getOriginalGroupId(),
27301                                            journalArticleModelImpl.getOriginalClassNameId(),
27302                                            journalArticleModelImpl.getOriginalStructureId()
27303                                    };
27304    
27305                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
27306                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
27307                    }
27308    
27309                    args = new Object[] {
27310                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
27311                                    journalArticle.getVersion()
27312                            };
27313    
27314                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
27315                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
27316    
27317                    if ((journalArticleModelImpl.getColumnBitmask() &
27318                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
27319                            args = new Object[] {
27320                                            journalArticleModelImpl.getOriginalGroupId(),
27321                                            journalArticleModelImpl.getOriginalArticleId(),
27322                                            journalArticleModelImpl.getOriginalVersion()
27323                                    };
27324    
27325                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
27326                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
27327                    }
27328            }
27329    
27330            /**
27331             * Creates a new journal article with the primary key. Does not add the journal article to the database.
27332             *
27333             * @param id the primary key for the new journal article
27334             * @return the new journal article
27335             */
27336            @Override
27337            public JournalArticle create(long id) {
27338                    JournalArticle journalArticle = new JournalArticleImpl();
27339    
27340                    journalArticle.setNew(true);
27341                    journalArticle.setPrimaryKey(id);
27342    
27343                    String uuid = PortalUUIDUtil.generate();
27344    
27345                    journalArticle.setUuid(uuid);
27346    
27347                    return journalArticle;
27348            }
27349    
27350            /**
27351             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
27352             *
27353             * @param id the primary key of the journal article
27354             * @return the journal article that was removed
27355             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27356             * @throws SystemException if a system exception occurred
27357             */
27358            @Override
27359            public JournalArticle remove(long id)
27360                    throws NoSuchArticleException, SystemException {
27361                    return remove((Serializable)id);
27362            }
27363    
27364            /**
27365             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
27366             *
27367             * @param primaryKey the primary key of the journal article
27368             * @return the journal article that was removed
27369             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27370             * @throws SystemException if a system exception occurred
27371             */
27372            @Override
27373            public JournalArticle remove(Serializable primaryKey)
27374                    throws NoSuchArticleException, SystemException {
27375                    Session session = null;
27376    
27377                    try {
27378                            session = openSession();
27379    
27380                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
27381                                            primaryKey);
27382    
27383                            if (journalArticle == null) {
27384                                    if (_log.isWarnEnabled()) {
27385                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
27386                                    }
27387    
27388                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
27389                                            primaryKey);
27390                            }
27391    
27392                            return remove(journalArticle);
27393                    }
27394                    catch (NoSuchArticleException nsee) {
27395                            throw nsee;
27396                    }
27397                    catch (Exception e) {
27398                            throw processException(e);
27399                    }
27400                    finally {
27401                            closeSession(session);
27402                    }
27403            }
27404    
27405            @Override
27406            protected JournalArticle removeImpl(JournalArticle journalArticle)
27407                    throws SystemException {
27408                    journalArticle = toUnwrappedModel(journalArticle);
27409    
27410                    Session session = null;
27411    
27412                    try {
27413                            session = openSession();
27414    
27415                            if (!session.contains(journalArticle)) {
27416                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
27417                                                    journalArticle.getPrimaryKeyObj());
27418                            }
27419    
27420                            if (journalArticle != null) {
27421                                    session.delete(journalArticle);
27422                            }
27423                    }
27424                    catch (Exception e) {
27425                            throw processException(e);
27426                    }
27427                    finally {
27428                            closeSession(session);
27429                    }
27430    
27431                    if (journalArticle != null) {
27432                            clearCache(journalArticle);
27433                    }
27434    
27435                    return journalArticle;
27436            }
27437    
27438            @Override
27439            public JournalArticle updateImpl(
27440                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
27441                    throws SystemException {
27442                    journalArticle = toUnwrappedModel(journalArticle);
27443    
27444                    boolean isNew = journalArticle.isNew();
27445    
27446                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
27447    
27448                    if (Validator.isNull(journalArticle.getUuid())) {
27449                            String uuid = PortalUUIDUtil.generate();
27450    
27451                            journalArticle.setUuid(uuid);
27452                    }
27453    
27454                    Session session = null;
27455    
27456                    try {
27457                            session = openSession();
27458    
27459                            if (journalArticle.isNew()) {
27460                                    session.save(journalArticle);
27461    
27462                                    journalArticle.setNew(false);
27463                            }
27464                            else {
27465                                    session.merge(journalArticle);
27466                            }
27467                    }
27468                    catch (Exception e) {
27469                            throw processException(e);
27470                    }
27471                    finally {
27472                            closeSession(session);
27473                    }
27474    
27475                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
27476    
27477                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
27478                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
27479                    }
27480    
27481                    else {
27482                            if ((journalArticleModelImpl.getColumnBitmask() &
27483                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
27484                                    Object[] args = new Object[] {
27485                                                    journalArticleModelImpl.getOriginalUuid()
27486                                            };
27487    
27488                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
27489                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
27490                                            args);
27491    
27492                                    args = new Object[] { journalArticleModelImpl.getUuid() };
27493    
27494                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
27495                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
27496                                            args);
27497                            }
27498    
27499                            if ((journalArticleModelImpl.getColumnBitmask() &
27500                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
27501                                    Object[] args = new Object[] {
27502                                                    journalArticleModelImpl.getOriginalUuid(),
27503                                                    journalArticleModelImpl.getOriginalCompanyId()
27504                                            };
27505    
27506                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
27507                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
27508                                            args);
27509    
27510                                    args = new Object[] {
27511                                                    journalArticleModelImpl.getUuid(),
27512                                                    journalArticleModelImpl.getCompanyId()
27513                                            };
27514    
27515                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
27516                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
27517                                            args);
27518                            }
27519    
27520                            if ((journalArticleModelImpl.getColumnBitmask() &
27521                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
27522                                    Object[] args = new Object[] {
27523                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
27524                                            };
27525    
27526                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
27527                                            args);
27528                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
27529                                            args);
27530    
27531                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
27532    
27533                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
27534                                            args);
27535                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
27536                                            args);
27537                            }
27538    
27539                            if ((journalArticleModelImpl.getColumnBitmask() &
27540                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
27541                                    Object[] args = new Object[] {
27542                                                    journalArticleModelImpl.getOriginalGroupId()
27543                                            };
27544    
27545                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
27546                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
27547                                            args);
27548    
27549                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
27550    
27551                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
27552                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
27553                                            args);
27554                            }
27555    
27556                            if ((journalArticleModelImpl.getColumnBitmask() &
27557                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
27558                                    Object[] args = new Object[] {
27559                                                    journalArticleModelImpl.getOriginalCompanyId()
27560                                            };
27561    
27562                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
27563                                            args);
27564                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
27565                                            args);
27566    
27567                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
27568    
27569                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
27570                                            args);
27571                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
27572                                            args);
27573                            }
27574    
27575                            if ((journalArticleModelImpl.getColumnBitmask() &
27576                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
27577                                    Object[] args = new Object[] {
27578                                                    journalArticleModelImpl.getOriginalStructureId()
27579                                            };
27580    
27581                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
27582                                            args);
27583                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
27584                                            args);
27585    
27586                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
27587    
27588                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
27589                                            args);
27590                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
27591                                            args);
27592                            }
27593    
27594                            if ((journalArticleModelImpl.getColumnBitmask() &
27595                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
27596                                    Object[] args = new Object[] {
27597                                                    journalArticleModelImpl.getOriginalTemplateId()
27598                                            };
27599    
27600                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
27601                                            args);
27602                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
27603                                            args);
27604    
27605                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
27606    
27607                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
27608                                            args);
27609                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
27610                                            args);
27611                            }
27612    
27613                            if ((journalArticleModelImpl.getColumnBitmask() &
27614                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
27615                                    Object[] args = new Object[] {
27616                                                    journalArticleModelImpl.getOriginalLayoutUuid()
27617                                            };
27618    
27619                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
27620                                            args);
27621                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
27622                                            args);
27623    
27624                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
27625    
27626                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
27627                                            args);
27628                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
27629                                            args);
27630                            }
27631    
27632                            if ((journalArticleModelImpl.getColumnBitmask() &
27633                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
27634                                    Object[] args = new Object[] {
27635                                                    journalArticleModelImpl.getOriginalSmallImageId()
27636                                            };
27637    
27638                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
27639                                            args);
27640                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
27641                                            args);
27642    
27643                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
27644    
27645                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
27646                                            args);
27647                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
27648                                            args);
27649                            }
27650    
27651                            if ((journalArticleModelImpl.getColumnBitmask() &
27652                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
27653                                    Object[] args = new Object[] {
27654                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
27655                                                    journalArticleModelImpl.getOriginalStatus()
27656                                            };
27657    
27658                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
27659                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
27660                                            args);
27661    
27662                                    args = new Object[] {
27663                                                    journalArticleModelImpl.getResourcePrimKey(),
27664                                                    journalArticleModelImpl.getStatus()
27665                                            };
27666    
27667                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
27668                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
27669                                            args);
27670                            }
27671    
27672                            if ((journalArticleModelImpl.getColumnBitmask() &
27673                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
27674                                    Object[] args = new Object[] {
27675                                                    journalArticleModelImpl.getOriginalGroupId(),
27676                                                    journalArticleModelImpl.getOriginalUserId()
27677                                            };
27678    
27679                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
27680                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
27681                                            args);
27682    
27683                                    args = new Object[] {
27684                                                    journalArticleModelImpl.getGroupId(),
27685                                                    journalArticleModelImpl.getUserId()
27686                                            };
27687    
27688                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
27689                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
27690                                            args);
27691                            }
27692    
27693                            if ((journalArticleModelImpl.getColumnBitmask() &
27694                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
27695                                    Object[] args = new Object[] {
27696                                                    journalArticleModelImpl.getOriginalGroupId(),
27697                                                    journalArticleModelImpl.getOriginalFolderId()
27698                                            };
27699    
27700                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
27701                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
27702                                            args);
27703    
27704                                    args = new Object[] {
27705                                                    journalArticleModelImpl.getGroupId(),
27706                                                    journalArticleModelImpl.getFolderId()
27707                                            };
27708    
27709                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
27710                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
27711                                            args);
27712                            }
27713    
27714                            if ((journalArticleModelImpl.getColumnBitmask() &
27715                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
27716                                    Object[] args = new Object[] {
27717                                                    journalArticleModelImpl.getOriginalGroupId(),
27718                                                    journalArticleModelImpl.getOriginalArticleId()
27719                                            };
27720    
27721                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
27722                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
27723                                            args);
27724    
27725                                    args = new Object[] {
27726                                                    journalArticleModelImpl.getGroupId(),
27727                                                    journalArticleModelImpl.getArticleId()
27728                                            };
27729    
27730                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
27731                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
27732                                            args);
27733                            }
27734    
27735                            if ((journalArticleModelImpl.getColumnBitmask() &
27736                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
27737                                    Object[] args = new Object[] {
27738                                                    journalArticleModelImpl.getOriginalGroupId(),
27739                                                    journalArticleModelImpl.getOriginalUrlTitle()
27740                                            };
27741    
27742                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
27743                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
27744                                            args);
27745    
27746                                    args = new Object[] {
27747                                                    journalArticleModelImpl.getGroupId(),
27748                                                    journalArticleModelImpl.getUrlTitle()
27749                                            };
27750    
27751                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
27752                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
27753                                            args);
27754                            }
27755    
27756                            if ((journalArticleModelImpl.getColumnBitmask() &
27757                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
27758                                    Object[] args = new Object[] {
27759                                                    journalArticleModelImpl.getOriginalGroupId(),
27760                                                    journalArticleModelImpl.getOriginalStructureId()
27761                                            };
27762    
27763                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
27764                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
27765                                            args);
27766    
27767                                    args = new Object[] {
27768                                                    journalArticleModelImpl.getGroupId(),
27769                                                    journalArticleModelImpl.getStructureId()
27770                                            };
27771    
27772                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
27773                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
27774                                            args);
27775                            }
27776    
27777                            if ((journalArticleModelImpl.getColumnBitmask() &
27778                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
27779                                    Object[] args = new Object[] {
27780                                                    journalArticleModelImpl.getOriginalGroupId(),
27781                                                    journalArticleModelImpl.getOriginalTemplateId()
27782                                            };
27783    
27784                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
27785                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
27786                                            args);
27787    
27788                                    args = new Object[] {
27789                                                    journalArticleModelImpl.getGroupId(),
27790                                                    journalArticleModelImpl.getTemplateId()
27791                                            };
27792    
27793                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
27794                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
27795                                            args);
27796                            }
27797    
27798                            if ((journalArticleModelImpl.getColumnBitmask() &
27799                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
27800                                    Object[] args = new Object[] {
27801                                                    journalArticleModelImpl.getOriginalGroupId(),
27802                                                    journalArticleModelImpl.getOriginalLayoutUuid()
27803                                            };
27804    
27805                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
27806                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
27807                                            args);
27808    
27809                                    args = new Object[] {
27810                                                    journalArticleModelImpl.getGroupId(),
27811                                                    journalArticleModelImpl.getLayoutUuid()
27812                                            };
27813    
27814                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
27815                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
27816                                            args);
27817                            }
27818    
27819                            if ((journalArticleModelImpl.getColumnBitmask() &
27820                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
27821                                    Object[] args = new Object[] {
27822                                                    journalArticleModelImpl.getOriginalGroupId(),
27823                                                    journalArticleModelImpl.getOriginalStatus()
27824                                            };
27825    
27826                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
27827                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
27828                                            args);
27829    
27830                                    args = new Object[] {
27831                                                    journalArticleModelImpl.getGroupId(),
27832                                                    journalArticleModelImpl.getStatus()
27833                                            };
27834    
27835                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
27836                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
27837                                            args);
27838                            }
27839    
27840                            if ((journalArticleModelImpl.getColumnBitmask() &
27841                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
27842                                    Object[] args = new Object[] {
27843                                                    journalArticleModelImpl.getOriginalCompanyId(),
27844                                                    journalArticleModelImpl.getOriginalVersion()
27845                                            };
27846    
27847                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
27848                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
27849                                            args);
27850    
27851                                    args = new Object[] {
27852                                                    journalArticleModelImpl.getCompanyId(),
27853                                                    journalArticleModelImpl.getVersion()
27854                                            };
27855    
27856                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
27857                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
27858                                            args);
27859                            }
27860    
27861                            if ((journalArticleModelImpl.getColumnBitmask() &
27862                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
27863                                    Object[] args = new Object[] {
27864                                                    journalArticleModelImpl.getOriginalCompanyId(),
27865                                                    journalArticleModelImpl.getOriginalStatus()
27866                                            };
27867    
27868                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
27869                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
27870                                            args);
27871    
27872                                    args = new Object[] {
27873                                                    journalArticleModelImpl.getCompanyId(),
27874                                                    journalArticleModelImpl.getStatus()
27875                                            };
27876    
27877                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
27878                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
27879                                            args);
27880                            }
27881    
27882                            if ((journalArticleModelImpl.getColumnBitmask() &
27883                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
27884                                    Object[] args = new Object[] {
27885                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
27886                                                    journalArticleModelImpl.getOriginalIndexable(),
27887                                                    journalArticleModelImpl.getOriginalStatus()
27888                                            };
27889    
27890                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
27891                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
27892                                            args);
27893    
27894                                    args = new Object[] {
27895                                                    journalArticleModelImpl.getResourcePrimKey(),
27896                                                    journalArticleModelImpl.getIndexable(),
27897                                                    journalArticleModelImpl.getStatus()
27898                                            };
27899    
27900                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
27901                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
27902                                            args);
27903                            }
27904    
27905                            if ((journalArticleModelImpl.getColumnBitmask() &
27906                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
27907                                    Object[] args = new Object[] {
27908                                                    journalArticleModelImpl.getOriginalGroupId(),
27909                                                    journalArticleModelImpl.getOriginalFolderId(),
27910                                                    journalArticleModelImpl.getOriginalStatus()
27911                                            };
27912    
27913                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
27914                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
27915                                            args);
27916    
27917                                    args = new Object[] {
27918                                                    journalArticleModelImpl.getGroupId(),
27919                                                    journalArticleModelImpl.getFolderId(),
27920                                                    journalArticleModelImpl.getStatus()
27921                                            };
27922    
27923                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
27924                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
27925                                            args);
27926                            }
27927    
27928                            if ((journalArticleModelImpl.getColumnBitmask() &
27929                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
27930                                    Object[] args = new Object[] {
27931                                                    journalArticleModelImpl.getOriginalGroupId(),
27932                                                    journalArticleModelImpl.getOriginalClassNameId(),
27933                                                    journalArticleModelImpl.getOriginalClassPK()
27934                                            };
27935    
27936                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
27937                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
27938                                            args);
27939    
27940                                    args = new Object[] {
27941                                                    journalArticleModelImpl.getGroupId(),
27942                                                    journalArticleModelImpl.getClassNameId(),
27943                                                    journalArticleModelImpl.getClassPK()
27944                                            };
27945    
27946                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
27947                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
27948                                            args);
27949                            }
27950    
27951                            if ((journalArticleModelImpl.getColumnBitmask() &
27952                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
27953                                    Object[] args = new Object[] {
27954                                                    journalArticleModelImpl.getOriginalGroupId(),
27955                                                    journalArticleModelImpl.getOriginalClassNameId(),
27956                                                    journalArticleModelImpl.getOriginalTemplateId()
27957                                            };
27958    
27959                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
27960                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
27961                                            args);
27962    
27963                                    args = new Object[] {
27964                                                    journalArticleModelImpl.getGroupId(),
27965                                                    journalArticleModelImpl.getClassNameId(),
27966                                                    journalArticleModelImpl.getTemplateId()
27967                                            };
27968    
27969                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
27970                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
27971                                            args);
27972                            }
27973    
27974                            if ((journalArticleModelImpl.getColumnBitmask() &
27975                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
27976                                    Object[] args = new Object[] {
27977                                                    journalArticleModelImpl.getOriginalGroupId(),
27978                                                    journalArticleModelImpl.getOriginalClassNameId(),
27979                                                    journalArticleModelImpl.getOriginalLayoutUuid()
27980                                            };
27981    
27982                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
27983                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
27984                                            args);
27985    
27986                                    args = new Object[] {
27987                                                    journalArticleModelImpl.getGroupId(),
27988                                                    journalArticleModelImpl.getClassNameId(),
27989                                                    journalArticleModelImpl.getLayoutUuid()
27990                                            };
27991    
27992                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
27993                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
27994                                            args);
27995                            }
27996    
27997                            if ((journalArticleModelImpl.getColumnBitmask() &
27998                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
27999                                    Object[] args = new Object[] {
28000                                                    journalArticleModelImpl.getOriginalGroupId(),
28001                                                    journalArticleModelImpl.getOriginalUserId(),
28002                                                    journalArticleModelImpl.getOriginalClassNameId()
28003                                            };
28004    
28005                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
28006                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
28007                                            args);
28008    
28009                                    args = new Object[] {
28010                                                    journalArticleModelImpl.getGroupId(),
28011                                                    journalArticleModelImpl.getUserId(),
28012                                                    journalArticleModelImpl.getClassNameId()
28013                                            };
28014    
28015                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
28016                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
28017                                            args);
28018                            }
28019    
28020                            if ((journalArticleModelImpl.getColumnBitmask() &
28021                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
28022                                    Object[] args = new Object[] {
28023                                                    journalArticleModelImpl.getOriginalGroupId(),
28024                                                    journalArticleModelImpl.getOriginalArticleId(),
28025                                                    journalArticleModelImpl.getOriginalStatus()
28026                                            };
28027    
28028                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
28029                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
28030                                            args);
28031    
28032                                    args = new Object[] {
28033                                                    journalArticleModelImpl.getGroupId(),
28034                                                    journalArticleModelImpl.getArticleId(),
28035                                                    journalArticleModelImpl.getStatus()
28036                                            };
28037    
28038                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
28039                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
28040                                            args);
28041                            }
28042    
28043                            if ((journalArticleModelImpl.getColumnBitmask() &
28044                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
28045                                    Object[] args = new Object[] {
28046                                                    journalArticleModelImpl.getOriginalGroupId(),
28047                                                    journalArticleModelImpl.getOriginalUrlTitle(),
28048                                                    journalArticleModelImpl.getOriginalStatus()
28049                                            };
28050    
28051                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
28052                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
28053                                            args);
28054    
28055                                    args = new Object[] {
28056                                                    journalArticleModelImpl.getGroupId(),
28057                                                    journalArticleModelImpl.getUrlTitle(),
28058                                                    journalArticleModelImpl.getStatus()
28059                                            };
28060    
28061                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
28062                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
28063                                            args);
28064                            }
28065    
28066                            if ((journalArticleModelImpl.getColumnBitmask() &
28067                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
28068                                    Object[] args = new Object[] {
28069                                                    journalArticleModelImpl.getOriginalCompanyId(),
28070                                                    journalArticleModelImpl.getOriginalVersion(),
28071                                                    journalArticleModelImpl.getOriginalStatus()
28072                                            };
28073    
28074                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
28075                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
28076                                            args);
28077    
28078                                    args = new Object[] {
28079                                                    journalArticleModelImpl.getCompanyId(),
28080                                                    journalArticleModelImpl.getVersion(),
28081                                                    journalArticleModelImpl.getStatus()
28082                                            };
28083    
28084                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
28085                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
28086                                            args);
28087                            }
28088                    }
28089    
28090                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28091                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
28092                            journalArticle);
28093    
28094                    clearUniqueFindersCache(journalArticle);
28095                    cacheUniqueFindersCache(journalArticle);
28096    
28097                    return journalArticle;
28098            }
28099    
28100            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
28101                    if (journalArticle instanceof JournalArticleImpl) {
28102                            return journalArticle;
28103                    }
28104    
28105                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
28106    
28107                    journalArticleImpl.setNew(journalArticle.isNew());
28108                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
28109    
28110                    journalArticleImpl.setUuid(journalArticle.getUuid());
28111                    journalArticleImpl.setId(journalArticle.getId());
28112                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
28113                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
28114                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
28115                    journalArticleImpl.setUserId(journalArticle.getUserId());
28116                    journalArticleImpl.setUserName(journalArticle.getUserName());
28117                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
28118                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
28119                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
28120                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
28121                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
28122                    journalArticleImpl.setTreePath(journalArticle.getTreePath());
28123                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
28124                    journalArticleImpl.setVersion(journalArticle.getVersion());
28125                    journalArticleImpl.setTitle(journalArticle.getTitle());
28126                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
28127                    journalArticleImpl.setDescription(journalArticle.getDescription());
28128                    journalArticleImpl.setContent(journalArticle.getContent());
28129                    journalArticleImpl.setType(journalArticle.getType());
28130                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
28131                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
28132                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
28133                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
28134                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
28135                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
28136                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
28137                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
28138                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
28139                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
28140                    journalArticleImpl.setStatus(journalArticle.getStatus());
28141                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
28142                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
28143                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
28144    
28145                    return journalArticleImpl;
28146            }
28147    
28148            /**
28149             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
28150             *
28151             * @param primaryKey the primary key of the journal article
28152             * @return the journal article
28153             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28154             * @throws SystemException if a system exception occurred
28155             */
28156            @Override
28157            public JournalArticle findByPrimaryKey(Serializable primaryKey)
28158                    throws NoSuchArticleException, SystemException {
28159                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
28160    
28161                    if (journalArticle == null) {
28162                            if (_log.isWarnEnabled()) {
28163                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
28164                            }
28165    
28166                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
28167                                    primaryKey);
28168                    }
28169    
28170                    return journalArticle;
28171            }
28172    
28173            /**
28174             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
28175             *
28176             * @param id the primary key of the journal article
28177             * @return the journal article
28178             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28179             * @throws SystemException if a system exception occurred
28180             */
28181            @Override
28182            public JournalArticle findByPrimaryKey(long id)
28183                    throws NoSuchArticleException, SystemException {
28184                    return findByPrimaryKey((Serializable)id);
28185            }
28186    
28187            /**
28188             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
28189             *
28190             * @param primaryKey the primary key of the journal article
28191             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
28192             * @throws SystemException if a system exception occurred
28193             */
28194            @Override
28195            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
28196                    throws SystemException {
28197                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28198                                    JournalArticleImpl.class, primaryKey);
28199    
28200                    if (journalArticle == _nullJournalArticle) {
28201                            return null;
28202                    }
28203    
28204                    if (journalArticle == null) {
28205                            Session session = null;
28206    
28207                            try {
28208                                    session = openSession();
28209    
28210                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
28211                                                    primaryKey);
28212    
28213                                    if (journalArticle != null) {
28214                                            cacheResult(journalArticle);
28215                                    }
28216                                    else {
28217                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28218                                                    JournalArticleImpl.class, primaryKey,
28219                                                    _nullJournalArticle);
28220                                    }
28221                            }
28222                            catch (Exception e) {
28223                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28224                                            JournalArticleImpl.class, primaryKey);
28225    
28226                                    throw processException(e);
28227                            }
28228                            finally {
28229                                    closeSession(session);
28230                            }
28231                    }
28232    
28233                    return journalArticle;
28234            }
28235    
28236            /**
28237             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
28238             *
28239             * @param id the primary key of the journal article
28240             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
28241             * @throws SystemException if a system exception occurred
28242             */
28243            @Override
28244            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
28245                    return fetchByPrimaryKey((Serializable)id);
28246            }
28247    
28248            /**
28249             * Returns all the journal articles.
28250             *
28251             * @return the journal articles
28252             * @throws SystemException if a system exception occurred
28253             */
28254            @Override
28255            public List<JournalArticle> findAll() throws SystemException {
28256                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
28257            }
28258    
28259            /**
28260             * Returns a range of all the journal articles.
28261             *
28262             * <p>
28263             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28264             * </p>
28265             *
28266             * @param start the lower bound of the range of journal articles
28267             * @param end the upper bound of the range of journal articles (not inclusive)
28268             * @return the range of journal articles
28269             * @throws SystemException if a system exception occurred
28270             */
28271            @Override
28272            public List<JournalArticle> findAll(int start, int end)
28273                    throws SystemException {
28274                    return findAll(start, end, null);
28275            }
28276    
28277            /**
28278             * Returns an ordered range of all the journal articles.
28279             *
28280             * <p>
28281             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28282             * </p>
28283             *
28284             * @param start the lower bound of the range of journal articles
28285             * @param end the upper bound of the range of journal articles (not inclusive)
28286             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28287             * @return the ordered range of journal articles
28288             * @throws SystemException if a system exception occurred
28289             */
28290            @Override
28291            public List<JournalArticle> findAll(int start, int end,
28292                    OrderByComparator orderByComparator) throws SystemException {
28293                    boolean pagination = true;
28294                    FinderPath finderPath = null;
28295                    Object[] finderArgs = null;
28296    
28297                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
28298                                    (orderByComparator == null)) {
28299                            pagination = false;
28300                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
28301                            finderArgs = FINDER_ARGS_EMPTY;
28302                    }
28303                    else {
28304                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
28305                            finderArgs = new Object[] { start, end, orderByComparator };
28306                    }
28307    
28308                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
28309                                    finderArgs, this);
28310    
28311                    if (list == null) {
28312                            StringBundler query = null;
28313                            String sql = null;
28314    
28315                            if (orderByComparator != null) {
28316                                    query = new StringBundler(2 +
28317                                                    (orderByComparator.getOrderByFields().length * 3));
28318    
28319                                    query.append(_SQL_SELECT_JOURNALARTICLE);
28320    
28321                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28322                                            orderByComparator);
28323    
28324                                    sql = query.toString();
28325                            }
28326                            else {
28327                                    sql = _SQL_SELECT_JOURNALARTICLE;
28328    
28329                                    if (pagination) {
28330                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
28331                                    }
28332                            }
28333    
28334                            Session session = null;
28335    
28336                            try {
28337                                    session = openSession();
28338    
28339                                    Query q = session.createQuery(sql);
28340    
28341                                    if (!pagination) {
28342                                            list = (List<JournalArticle>)QueryUtil.list(q,
28343                                                            getDialect(), start, end, false);
28344    
28345                                            Collections.sort(list);
28346    
28347                                            list = new UnmodifiableList<JournalArticle>(list);
28348                                    }
28349                                    else {
28350                                            list = (List<JournalArticle>)QueryUtil.list(q,
28351                                                            getDialect(), start, end);
28352                                    }
28353    
28354                                    cacheResult(list);
28355    
28356                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
28357                            }
28358                            catch (Exception e) {
28359                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28360    
28361                                    throw processException(e);
28362                            }
28363                            finally {
28364                                    closeSession(session);
28365                            }
28366                    }
28367    
28368                    return list;
28369            }
28370    
28371            /**
28372             * Removes all the journal articles from the database.
28373             *
28374             * @throws SystemException if a system exception occurred
28375             */
28376            @Override
28377            public void removeAll() throws SystemException {
28378                    for (JournalArticle journalArticle : findAll()) {
28379                            remove(journalArticle);
28380                    }
28381            }
28382    
28383            /**
28384             * Returns the number of journal articles.
28385             *
28386             * @return the number of journal articles
28387             * @throws SystemException if a system exception occurred
28388             */
28389            @Override
28390            public int countAll() throws SystemException {
28391                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
28392                                    FINDER_ARGS_EMPTY, this);
28393    
28394                    if (count == null) {
28395                            Session session = null;
28396    
28397                            try {
28398                                    session = openSession();
28399    
28400                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
28401    
28402                                    count = (Long)q.uniqueResult();
28403    
28404                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
28405                                            FINDER_ARGS_EMPTY, count);
28406                            }
28407                            catch (Exception e) {
28408                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
28409                                            FINDER_ARGS_EMPTY);
28410    
28411                                    throw processException(e);
28412                            }
28413                            finally {
28414                                    closeSession(session);
28415                            }
28416                    }
28417    
28418                    return count.intValue();
28419            }
28420    
28421            @Override
28422            protected Set<String> getBadColumnNames() {
28423                    return _badColumnNames;
28424            }
28425    
28426            /**
28427             * Initializes the journal article persistence.
28428             */
28429            public void afterPropertiesSet() {
28430                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
28431                                            com.liferay.portal.util.PropsUtil.get(
28432                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
28433    
28434                    if (listenerClassNames.length > 0) {
28435                            try {
28436                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
28437    
28438                                    for (String listenerClassName : listenerClassNames) {
28439                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
28440                                                            getClassLoader(), listenerClassName));
28441                                    }
28442    
28443                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
28444                            }
28445                            catch (Exception e) {
28446                                    _log.error(e);
28447                            }
28448                    }
28449            }
28450    
28451            public void destroy() {
28452                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
28453                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
28454                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28455                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28456            }
28457    
28458            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
28459            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
28460            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
28461            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
28462            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
28463            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
28464            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
28465                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
28466            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
28467                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
28468            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
28469            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
28470            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
28471            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
28472            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
28473            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
28474            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
28475            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
28476            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
28477            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
28478                                    "uuid", "id", "type"
28479                            });
28480            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
28481                            @Override
28482                            public Object clone() {
28483                                    return this;
28484                            }
28485    
28486                            @Override
28487                            public CacheModel<JournalArticle> toCacheModel() {
28488                                    return _nullJournalArticleCacheModel;
28489                            }
28490                    };
28491    
28492            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
28493                            @Override
28494                            public JournalArticle toEntityModel() {
28495                                    return _nullJournalArticle;
28496                            }
28497                    };
28498    }