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_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15597                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15598                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15599                            "findByLtD_S",
15600                            new String[] {
15601                                    Date.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_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15607                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15608                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
15609                            new String[] { Date.class.getName(), Integer.class.getName() });
15610    
15611            /**
15612             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
15613             *
15614             * @param displayDate the display date
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> findByLtD_S(Date displayDate, int status)
15621                    throws SystemException {
15622                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
15623                            QueryUtil.ALL_POS, null);
15624            }
15625    
15626            /**
15627             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#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 displayDate the display date
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> findByLtD_S(Date displayDate, int status,
15642                    int start, int end) throws SystemException {
15643                    return findByLtD_S(displayDate, status, start, end, null);
15644            }
15645    
15646            /**
15647             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#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 displayDate the display date
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> findByLtD_S(Date displayDate, 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_LTD_S;
15670                    finderArgs = new Object[] {
15671                                    displayDate, 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 (!Validator.equals(displayDate,
15682                                                            journalArticle.getDisplayDate()) ||
15683                                                    (status != journalArticle.getStatus())) {
15684                                            list = null;
15685    
15686                                            break;
15687                                    }
15688                            }
15689                    }
15690    
15691                    if (list == null) {
15692                            StringBundler query = null;
15693    
15694                            if (orderByComparator != null) {
15695                                    query = new StringBundler(4 +
15696                                                    (orderByComparator.getOrderByFields().length * 3));
15697                            }
15698                            else {
15699                                    query = new StringBundler(4);
15700                            }
15701    
15702                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15703    
15704                            boolean bindDisplayDate = false;
15705    
15706                            if (displayDate == null) {
15707                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
15708                            }
15709                            else {
15710                                    bindDisplayDate = true;
15711    
15712                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
15713                            }
15714    
15715                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
15716    
15717                            if (orderByComparator != null) {
15718                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15719                                            orderByComparator);
15720                            }
15721                            else
15722                             if (pagination) {
15723                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15724                            }
15725    
15726                            String sql = query.toString();
15727    
15728                            Session session = null;
15729    
15730                            try {
15731                                    session = openSession();
15732    
15733                                    Query q = session.createQuery(sql);
15734    
15735                                    QueryPos qPos = QueryPos.getInstance(q);
15736    
15737                                    if (bindDisplayDate) {
15738                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15739                                    }
15740    
15741                                    qPos.add(status);
15742    
15743                                    if (!pagination) {
15744                                            list = (List<JournalArticle>)QueryUtil.list(q,
15745                                                            getDialect(), start, end, false);
15746    
15747                                            Collections.sort(list);
15748    
15749                                            list = new UnmodifiableList<JournalArticle>(list);
15750                                    }
15751                                    else {
15752                                            list = (List<JournalArticle>)QueryUtil.list(q,
15753                                                            getDialect(), start, end);
15754                                    }
15755    
15756                                    cacheResult(list);
15757    
15758                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15759                            }
15760                            catch (Exception e) {
15761                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15762    
15763                                    throw processException(e);
15764                            }
15765                            finally {
15766                                    closeSession(session);
15767                            }
15768                    }
15769    
15770                    return list;
15771            }
15772    
15773            /**
15774             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
15775             *
15776             * @param displayDate the display date
15777             * @param status the status
15778             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15779             * @return the first matching journal article
15780             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15781             * @throws SystemException if a system exception occurred
15782             */
15783            @Override
15784            public JournalArticle findByLtD_S_First(Date displayDate, int status,
15785                    OrderByComparator orderByComparator)
15786                    throws NoSuchArticleException, SystemException {
15787                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
15788                                    orderByComparator);
15789    
15790                    if (journalArticle != null) {
15791                            return journalArticle;
15792                    }
15793    
15794                    StringBundler msg = new StringBundler(6);
15795    
15796                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15797    
15798                    msg.append("displayDate=");
15799                    msg.append(displayDate);
15800    
15801                    msg.append(", status=");
15802                    msg.append(status);
15803    
15804                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15805    
15806                    throw new NoSuchArticleException(msg.toString());
15807            }
15808    
15809            /**
15810             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
15811             *
15812             * @param displayDate the display date
15813             * @param status the status
15814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15815             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15816             * @throws SystemException if a system exception occurred
15817             */
15818            @Override
15819            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
15820                    OrderByComparator orderByComparator) throws SystemException {
15821                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
15822                                    orderByComparator);
15823    
15824                    if (!list.isEmpty()) {
15825                            return list.get(0);
15826                    }
15827    
15828                    return null;
15829            }
15830    
15831            /**
15832             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
15833             *
15834             * @param displayDate the display date
15835             * @param status the status
15836             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15837             * @return the last matching journal article
15838             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15839             * @throws SystemException if a system exception occurred
15840             */
15841            @Override
15842            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
15843                    OrderByComparator orderByComparator)
15844                    throws NoSuchArticleException, SystemException {
15845                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
15846                                    orderByComparator);
15847    
15848                    if (journalArticle != null) {
15849                            return journalArticle;
15850                    }
15851    
15852                    StringBundler msg = new StringBundler(6);
15853    
15854                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15855    
15856                    msg.append("displayDate=");
15857                    msg.append(displayDate);
15858    
15859                    msg.append(", status=");
15860                    msg.append(status);
15861    
15862                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15863    
15864                    throw new NoSuchArticleException(msg.toString());
15865            }
15866    
15867            /**
15868             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
15869             *
15870             * @param displayDate the display date
15871             * @param status the status
15872             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15873             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15874             * @throws SystemException if a system exception occurred
15875             */
15876            @Override
15877            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
15878                    OrderByComparator orderByComparator) throws SystemException {
15879                    int count = countByLtD_S(displayDate, status);
15880    
15881                    if (count == 0) {
15882                            return null;
15883                    }
15884    
15885                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
15886                                    count, orderByComparator);
15887    
15888                    if (!list.isEmpty()) {
15889                            return list.get(0);
15890                    }
15891    
15892                    return null;
15893            }
15894    
15895            /**
15896             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
15897             *
15898             * @param id the primary key of the current journal article
15899             * @param displayDate the display date
15900             * @param status the status
15901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15902             * @return the previous, current, and next journal article
15903             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15904             * @throws SystemException if a system exception occurred
15905             */
15906            @Override
15907            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
15908                    int status, OrderByComparator orderByComparator)
15909                    throws NoSuchArticleException, SystemException {
15910                    JournalArticle journalArticle = findByPrimaryKey(id);
15911    
15912                    Session session = null;
15913    
15914                    try {
15915                            session = openSession();
15916    
15917                            JournalArticle[] array = new JournalArticleImpl[3];
15918    
15919                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
15920                                            displayDate, status, orderByComparator, true);
15921    
15922                            array[1] = journalArticle;
15923    
15924                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
15925                                            displayDate, status, orderByComparator, false);
15926    
15927                            return array;
15928                    }
15929                    catch (Exception e) {
15930                            throw processException(e);
15931                    }
15932                    finally {
15933                            closeSession(session);
15934                    }
15935            }
15936    
15937            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
15938                    JournalArticle journalArticle, Date displayDate, int status,
15939                    OrderByComparator orderByComparator, boolean previous) {
15940                    StringBundler query = null;
15941    
15942                    if (orderByComparator != null) {
15943                            query = new StringBundler(6 +
15944                                            (orderByComparator.getOrderByFields().length * 6));
15945                    }
15946                    else {
15947                            query = new StringBundler(3);
15948                    }
15949    
15950                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15951    
15952                    boolean bindDisplayDate = false;
15953    
15954                    if (displayDate == null) {
15955                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
15956                    }
15957                    else {
15958                            bindDisplayDate = true;
15959    
15960                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
15961                    }
15962    
15963                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
15964    
15965                    if (orderByComparator != null) {
15966                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15967    
15968                            if (orderByConditionFields.length > 0) {
15969                                    query.append(WHERE_AND);
15970                            }
15971    
15972                            for (int i = 0; i < orderByConditionFields.length; i++) {
15973                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15974                                    query.append(orderByConditionFields[i]);
15975    
15976                                    if ((i + 1) < orderByConditionFields.length) {
15977                                            if (orderByComparator.isAscending() ^ previous) {
15978                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15979                                            }
15980                                            else {
15981                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15982                                            }
15983                                    }
15984                                    else {
15985                                            if (orderByComparator.isAscending() ^ previous) {
15986                                                    query.append(WHERE_GREATER_THAN);
15987                                            }
15988                                            else {
15989                                                    query.append(WHERE_LESSER_THAN);
15990                                            }
15991                                    }
15992                            }
15993    
15994                            query.append(ORDER_BY_CLAUSE);
15995    
15996                            String[] orderByFields = orderByComparator.getOrderByFields();
15997    
15998                            for (int i = 0; i < orderByFields.length; i++) {
15999                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16000                                    query.append(orderByFields[i]);
16001    
16002                                    if ((i + 1) < orderByFields.length) {
16003                                            if (orderByComparator.isAscending() ^ previous) {
16004                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16005                                            }
16006                                            else {
16007                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16008                                            }
16009                                    }
16010                                    else {
16011                                            if (orderByComparator.isAscending() ^ previous) {
16012                                                    query.append(ORDER_BY_ASC);
16013                                            }
16014                                            else {
16015                                                    query.append(ORDER_BY_DESC);
16016                                            }
16017                                    }
16018                            }
16019                    }
16020                    else {
16021                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16022                    }
16023    
16024                    String sql = query.toString();
16025    
16026                    Query q = session.createQuery(sql);
16027    
16028                    q.setFirstResult(0);
16029                    q.setMaxResults(2);
16030    
16031                    QueryPos qPos = QueryPos.getInstance(q);
16032    
16033                    if (bindDisplayDate) {
16034                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16035                    }
16036    
16037                    qPos.add(status);
16038    
16039                    if (orderByComparator != null) {
16040                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16041    
16042                            for (Object value : values) {
16043                                    qPos.add(value);
16044                            }
16045                    }
16046    
16047                    List<JournalArticle> list = q.list();
16048    
16049                    if (list.size() == 2) {
16050                            return list.get(1);
16051                    }
16052                    else {
16053                            return null;
16054                    }
16055            }
16056    
16057            /**
16058             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
16059             *
16060             * @param displayDate the display date
16061             * @param status the status
16062             * @throws SystemException if a system exception occurred
16063             */
16064            @Override
16065            public void removeByLtD_S(Date displayDate, int status)
16066                    throws SystemException {
16067                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
16068                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16069                            remove(journalArticle);
16070                    }
16071            }
16072    
16073            /**
16074             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
16075             *
16076             * @param displayDate the display date
16077             * @param status the status
16078             * @return the number of matching journal articles
16079             * @throws SystemException if a system exception occurred
16080             */
16081            @Override
16082            public int countByLtD_S(Date displayDate, int status)
16083                    throws SystemException {
16084                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
16085    
16086                    Object[] finderArgs = new Object[] { displayDate, status };
16087    
16088                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16089                                    this);
16090    
16091                    if (count == null) {
16092                            StringBundler query = new StringBundler(3);
16093    
16094                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16095    
16096                            boolean bindDisplayDate = false;
16097    
16098                            if (displayDate == null) {
16099                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
16100                            }
16101                            else {
16102                                    bindDisplayDate = true;
16103    
16104                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
16105                            }
16106    
16107                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
16108    
16109                            String sql = query.toString();
16110    
16111                            Session session = null;
16112    
16113                            try {
16114                                    session = openSession();
16115    
16116                                    Query q = session.createQuery(sql);
16117    
16118                                    QueryPos qPos = QueryPos.getInstance(q);
16119    
16120                                    if (bindDisplayDate) {
16121                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16122                                    }
16123    
16124                                    qPos.add(status);
16125    
16126                                    count = (Long)q.uniqueResult();
16127    
16128                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16129                            }
16130                            catch (Exception e) {
16131                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16132    
16133                                    throw processException(e);
16134                            }
16135                            finally {
16136                                    closeSession(session);
16137                            }
16138                    }
16139    
16140                    return count.intValue();
16141            }
16142    
16143            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
16144            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
16145            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
16146            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16147                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16148                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16149                            "findByR_I_S",
16150                            new String[] {
16151                                    Long.class.getName(), Boolean.class.getName(),
16152                                    Integer.class.getName(),
16153                                    
16154                            Integer.class.getName(), Integer.class.getName(),
16155                                    OrderByComparator.class.getName()
16156                            });
16157            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16158                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16159                            JournalArticleImpl.class,
16160                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
16161                            new String[] {
16162                                    Long.class.getName(), Boolean.class.getName(),
16163                                    Integer.class.getName()
16164                            },
16165                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
16166                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
16167                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
16168                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16169                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16170            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16171                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16172                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
16173                            new String[] {
16174                                    Long.class.getName(), Boolean.class.getName(),
16175                                    Integer.class.getName()
16176                            });
16177            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16178                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16179                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
16180                            new String[] {
16181                                    Long.class.getName(), Boolean.class.getName(),
16182                                    Integer.class.getName()
16183                            });
16184    
16185            /**
16186             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16187             *
16188             * @param resourcePrimKey the resource prim key
16189             * @param indexable the indexable
16190             * @param status the status
16191             * @return the matching journal articles
16192             * @throws SystemException if a system exception occurred
16193             */
16194            @Override
16195            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16196                    boolean indexable, int status) throws SystemException {
16197                    return findByR_I_S(resourcePrimKey, indexable, status,
16198                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16199            }
16200    
16201            /**
16202             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16203             *
16204             * <p>
16205             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16206             * </p>
16207             *
16208             * @param resourcePrimKey the resource prim key
16209             * @param indexable the indexable
16210             * @param status the status
16211             * @param start the lower bound of the range of journal articles
16212             * @param end the upper bound of the range of journal articles (not inclusive)
16213             * @return the range of matching journal articles
16214             * @throws SystemException if a system exception occurred
16215             */
16216            @Override
16217            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16218                    boolean indexable, int status, int start, int end)
16219                    throws SystemException {
16220                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
16221            }
16222    
16223            /**
16224             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16225             *
16226             * <p>
16227             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16228             * </p>
16229             *
16230             * @param resourcePrimKey the resource prim key
16231             * @param indexable the indexable
16232             * @param status the status
16233             * @param start the lower bound of the range of journal articles
16234             * @param end the upper bound of the range of journal articles (not inclusive)
16235             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16236             * @return the ordered range of matching journal articles
16237             * @throws SystemException if a system exception occurred
16238             */
16239            @Override
16240            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16241                    boolean indexable, int status, int start, int end,
16242                    OrderByComparator orderByComparator) throws SystemException {
16243                    boolean pagination = true;
16244                    FinderPath finderPath = null;
16245                    Object[] finderArgs = null;
16246    
16247                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16248                                    (orderByComparator == null)) {
16249                            pagination = false;
16250                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
16251                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
16252                    }
16253                    else {
16254                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
16255                            finderArgs = new Object[] {
16256                                            resourcePrimKey, indexable, status,
16257                                            
16258                                            start, end, orderByComparator
16259                                    };
16260                    }
16261    
16262                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16263                                    finderArgs, this);
16264    
16265                    if ((list != null) && !list.isEmpty()) {
16266                            for (JournalArticle journalArticle : list) {
16267                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
16268                                                    (indexable != journalArticle.getIndexable()) ||
16269                                                    (status != journalArticle.getStatus())) {
16270                                            list = null;
16271    
16272                                            break;
16273                                    }
16274                            }
16275                    }
16276    
16277                    if (list == null) {
16278                            StringBundler query = null;
16279    
16280                            if (orderByComparator != null) {
16281                                    query = new StringBundler(5 +
16282                                                    (orderByComparator.getOrderByFields().length * 3));
16283                            }
16284                            else {
16285                                    query = new StringBundler(5);
16286                            }
16287    
16288                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16289    
16290                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
16291    
16292                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
16293    
16294                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
16295    
16296                            if (orderByComparator != null) {
16297                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16298                                            orderByComparator);
16299                            }
16300                            else
16301                             if (pagination) {
16302                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16303                            }
16304    
16305                            String sql = query.toString();
16306    
16307                            Session session = null;
16308    
16309                            try {
16310                                    session = openSession();
16311    
16312                                    Query q = session.createQuery(sql);
16313    
16314                                    QueryPos qPos = QueryPos.getInstance(q);
16315    
16316                                    qPos.add(resourcePrimKey);
16317    
16318                                    qPos.add(indexable);
16319    
16320                                    qPos.add(status);
16321    
16322                                    if (!pagination) {
16323                                            list = (List<JournalArticle>)QueryUtil.list(q,
16324                                                            getDialect(), start, end, false);
16325    
16326                                            Collections.sort(list);
16327    
16328                                            list = new UnmodifiableList<JournalArticle>(list);
16329                                    }
16330                                    else {
16331                                            list = (List<JournalArticle>)QueryUtil.list(q,
16332                                                            getDialect(), start, end);
16333                                    }
16334    
16335                                    cacheResult(list);
16336    
16337                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16338                            }
16339                            catch (Exception e) {
16340                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16341    
16342                                    throw processException(e);
16343                            }
16344                            finally {
16345                                    closeSession(session);
16346                            }
16347                    }
16348    
16349                    return list;
16350            }
16351    
16352            /**
16353             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16354             *
16355             * @param resourcePrimKey the resource prim key
16356             * @param indexable the indexable
16357             * @param status the status
16358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16359             * @return the first matching journal article
16360             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16361             * @throws SystemException if a system exception occurred
16362             */
16363            @Override
16364            public JournalArticle findByR_I_S_First(long resourcePrimKey,
16365                    boolean indexable, int status, OrderByComparator orderByComparator)
16366                    throws NoSuchArticleException, SystemException {
16367                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
16368                                    indexable, status, orderByComparator);
16369    
16370                    if (journalArticle != null) {
16371                            return journalArticle;
16372                    }
16373    
16374                    StringBundler msg = new StringBundler(8);
16375    
16376                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16377    
16378                    msg.append("resourcePrimKey=");
16379                    msg.append(resourcePrimKey);
16380    
16381                    msg.append(", indexable=");
16382                    msg.append(indexable);
16383    
16384                    msg.append(", status=");
16385                    msg.append(status);
16386    
16387                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16388    
16389                    throw new NoSuchArticleException(msg.toString());
16390            }
16391    
16392            /**
16393             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16394             *
16395             * @param resourcePrimKey the resource prim key
16396             * @param indexable the indexable
16397             * @param status the status
16398             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16399             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16400             * @throws SystemException if a system exception occurred
16401             */
16402            @Override
16403            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
16404                    boolean indexable, int status, OrderByComparator orderByComparator)
16405                    throws SystemException {
16406                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
16407                                    status, 0, 1, orderByComparator);
16408    
16409                    if (!list.isEmpty()) {
16410                            return list.get(0);
16411                    }
16412    
16413                    return null;
16414            }
16415    
16416            /**
16417             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16418             *
16419             * @param resourcePrimKey the resource prim key
16420             * @param indexable the indexable
16421             * @param status the status
16422             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16423             * @return the last matching journal article
16424             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16425             * @throws SystemException if a system exception occurred
16426             */
16427            @Override
16428            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
16429                    boolean indexable, int status, OrderByComparator orderByComparator)
16430                    throws NoSuchArticleException, SystemException {
16431                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
16432                                    indexable, status, orderByComparator);
16433    
16434                    if (journalArticle != null) {
16435                            return journalArticle;
16436                    }
16437    
16438                    StringBundler msg = new StringBundler(8);
16439    
16440                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16441    
16442                    msg.append("resourcePrimKey=");
16443                    msg.append(resourcePrimKey);
16444    
16445                    msg.append(", indexable=");
16446                    msg.append(indexable);
16447    
16448                    msg.append(", status=");
16449                    msg.append(status);
16450    
16451                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16452    
16453                    throw new NoSuchArticleException(msg.toString());
16454            }
16455    
16456            /**
16457             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16458             *
16459             * @param resourcePrimKey the resource prim key
16460             * @param indexable the indexable
16461             * @param status the status
16462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16463             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16464             * @throws SystemException if a system exception occurred
16465             */
16466            @Override
16467            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
16468                    boolean indexable, int status, OrderByComparator orderByComparator)
16469                    throws SystemException {
16470                    int count = countByR_I_S(resourcePrimKey, indexable, status);
16471    
16472                    if (count == 0) {
16473                            return null;
16474                    }
16475    
16476                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
16477                                    status, count - 1, count, orderByComparator);
16478    
16479                    if (!list.isEmpty()) {
16480                            return list.get(0);
16481                    }
16482    
16483                    return null;
16484            }
16485    
16486            /**
16487             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16488             *
16489             * @param id the primary key of the current journal article
16490             * @param resourcePrimKey the resource prim key
16491             * @param indexable the indexable
16492             * @param status the status
16493             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16494             * @return the previous, current, and next journal article
16495             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16496             * @throws SystemException if a system exception occurred
16497             */
16498            @Override
16499            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
16500                    long resourcePrimKey, boolean indexable, int status,
16501                    OrderByComparator orderByComparator)
16502                    throws NoSuchArticleException, SystemException {
16503                    JournalArticle journalArticle = findByPrimaryKey(id);
16504    
16505                    Session session = null;
16506    
16507                    try {
16508                            session = openSession();
16509    
16510                            JournalArticle[] array = new JournalArticleImpl[3];
16511    
16512                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
16513                                            resourcePrimKey, indexable, status, orderByComparator, true);
16514    
16515                            array[1] = journalArticle;
16516    
16517                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
16518                                            resourcePrimKey, indexable, status, orderByComparator, false);
16519    
16520                            return array;
16521                    }
16522                    catch (Exception e) {
16523                            throw processException(e);
16524                    }
16525                    finally {
16526                            closeSession(session);
16527                    }
16528            }
16529    
16530            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
16531                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
16532                    int status, OrderByComparator orderByComparator, boolean previous) {
16533                    StringBundler query = null;
16534    
16535                    if (orderByComparator != null) {
16536                            query = new StringBundler(6 +
16537                                            (orderByComparator.getOrderByFields().length * 6));
16538                    }
16539                    else {
16540                            query = new StringBundler(3);
16541                    }
16542    
16543                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16544    
16545                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
16546    
16547                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
16548    
16549                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
16550    
16551                    if (orderByComparator != null) {
16552                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16553    
16554                            if (orderByConditionFields.length > 0) {
16555                                    query.append(WHERE_AND);
16556                            }
16557    
16558                            for (int i = 0; i < orderByConditionFields.length; i++) {
16559                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16560                                    query.append(orderByConditionFields[i]);
16561    
16562                                    if ((i + 1) < orderByConditionFields.length) {
16563                                            if (orderByComparator.isAscending() ^ previous) {
16564                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16565                                            }
16566                                            else {
16567                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16568                                            }
16569                                    }
16570                                    else {
16571                                            if (orderByComparator.isAscending() ^ previous) {
16572                                                    query.append(WHERE_GREATER_THAN);
16573                                            }
16574                                            else {
16575                                                    query.append(WHERE_LESSER_THAN);
16576                                            }
16577                                    }
16578                            }
16579    
16580                            query.append(ORDER_BY_CLAUSE);
16581    
16582                            String[] orderByFields = orderByComparator.getOrderByFields();
16583    
16584                            for (int i = 0; i < orderByFields.length; i++) {
16585                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16586                                    query.append(orderByFields[i]);
16587    
16588                                    if ((i + 1) < orderByFields.length) {
16589                                            if (orderByComparator.isAscending() ^ previous) {
16590                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16591                                            }
16592                                            else {
16593                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16594                                            }
16595                                    }
16596                                    else {
16597                                            if (orderByComparator.isAscending() ^ previous) {
16598                                                    query.append(ORDER_BY_ASC);
16599                                            }
16600                                            else {
16601                                                    query.append(ORDER_BY_DESC);
16602                                            }
16603                                    }
16604                            }
16605                    }
16606                    else {
16607                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16608                    }
16609    
16610                    String sql = query.toString();
16611    
16612                    Query q = session.createQuery(sql);
16613    
16614                    q.setFirstResult(0);
16615                    q.setMaxResults(2);
16616    
16617                    QueryPos qPos = QueryPos.getInstance(q);
16618    
16619                    qPos.add(resourcePrimKey);
16620    
16621                    qPos.add(indexable);
16622    
16623                    qPos.add(status);
16624    
16625                    if (orderByComparator != null) {
16626                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16627    
16628                            for (Object value : values) {
16629                                    qPos.add(value);
16630                            }
16631                    }
16632    
16633                    List<JournalArticle> list = q.list();
16634    
16635                    if (list.size() == 2) {
16636                            return list.get(1);
16637                    }
16638                    else {
16639                            return null;
16640                    }
16641            }
16642    
16643            /**
16644             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
16645             *
16646             * <p>
16647             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16648             * </p>
16649             *
16650             * @param resourcePrimKey the resource prim key
16651             * @param indexable the indexable
16652             * @param statuses the statuses
16653             * @return the matching journal articles
16654             * @throws SystemException if a system exception occurred
16655             */
16656            @Override
16657            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16658                    boolean indexable, int[] statuses) throws SystemException {
16659                    return findByR_I_S(resourcePrimKey, indexable, statuses,
16660                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16661            }
16662    
16663            /**
16664             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
16665             *
16666             * <p>
16667             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16668             * </p>
16669             *
16670             * @param resourcePrimKey the resource prim key
16671             * @param indexable the indexable
16672             * @param statuses the statuses
16673             * @param start the lower bound of the range of journal articles
16674             * @param end the upper bound of the range of journal articles (not inclusive)
16675             * @return the range of matching journal articles
16676             * @throws SystemException if a system exception occurred
16677             */
16678            @Override
16679            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16680                    boolean indexable, int[] statuses, int start, int end)
16681                    throws SystemException {
16682                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
16683                            null);
16684            }
16685    
16686            /**
16687             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
16688             *
16689             * <p>
16690             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16691             * </p>
16692             *
16693             * @param resourcePrimKey the resource prim key
16694             * @param indexable the indexable
16695             * @param statuses the statuses
16696             * @param start the lower bound of the range of journal articles
16697             * @param end the upper bound of the range of journal articles (not inclusive)
16698             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16699             * @return the ordered range of matching journal articles
16700             * @throws SystemException if a system exception occurred
16701             */
16702            @Override
16703            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
16704                    boolean indexable, int[] statuses, int start, int end,
16705                    OrderByComparator orderByComparator) throws SystemException {
16706                    if ((statuses != null) && (statuses.length == 1)) {
16707                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
16708                                    end, orderByComparator);
16709                    }
16710    
16711                    boolean pagination = true;
16712                    Object[] finderArgs = null;
16713    
16714                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16715                                    (orderByComparator == null)) {
16716                            pagination = false;
16717                            finderArgs = new Object[] {
16718                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
16719                                    };
16720                    }
16721                    else {
16722                            finderArgs = new Object[] {
16723                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
16724                                            
16725                                            start, end, orderByComparator
16726                                    };
16727                    }
16728    
16729                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
16730                                    finderArgs, this);
16731    
16732                    if ((list != null) && !list.isEmpty()) {
16733                            for (JournalArticle journalArticle : list) {
16734                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
16735                                                    (indexable != journalArticle.getIndexable()) ||
16736                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
16737                                            list = null;
16738    
16739                                            break;
16740                                    }
16741                            }
16742                    }
16743    
16744                    if (list == null) {
16745                            StringBundler query = new StringBundler();
16746    
16747                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16748    
16749                            boolean conjunctionable = false;
16750    
16751                            if (conjunctionable) {
16752                                    query.append(WHERE_AND);
16753                            }
16754    
16755                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
16756    
16757                            conjunctionable = true;
16758    
16759                            if (conjunctionable) {
16760                                    query.append(WHERE_AND);
16761                            }
16762    
16763                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
16764    
16765                            conjunctionable = true;
16766    
16767                            if ((statuses == null) || (statuses.length > 0)) {
16768                                    if (conjunctionable) {
16769                                            query.append(WHERE_AND);
16770                                    }
16771    
16772                                    query.append(StringPool.OPEN_PARENTHESIS);
16773    
16774                                    for (int i = 0; i < statuses.length; i++) {
16775                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
16776    
16777                                            if ((i + 1) < statuses.length) {
16778                                                    query.append(WHERE_OR);
16779                                            }
16780                                    }
16781    
16782                                    query.append(StringPool.CLOSE_PARENTHESIS);
16783    
16784                                    conjunctionable = true;
16785                            }
16786    
16787                            if (orderByComparator != null) {
16788                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16789                                            orderByComparator);
16790                            }
16791                            else
16792                             if (pagination) {
16793                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16794                            }
16795    
16796                            String sql = query.toString();
16797    
16798                            Session session = null;
16799    
16800                            try {
16801                                    session = openSession();
16802    
16803                                    Query q = session.createQuery(sql);
16804    
16805                                    QueryPos qPos = QueryPos.getInstance(q);
16806    
16807                                    qPos.add(resourcePrimKey);
16808    
16809                                    qPos.add(indexable);
16810    
16811                                    if (statuses != null) {
16812                                            qPos.add(statuses);
16813                                    }
16814    
16815                                    if (!pagination) {
16816                                            list = (List<JournalArticle>)QueryUtil.list(q,
16817                                                            getDialect(), start, end, false);
16818    
16819                                            Collections.sort(list);
16820    
16821                                            list = new UnmodifiableList<JournalArticle>(list);
16822                                    }
16823                                    else {
16824                                            list = (List<JournalArticle>)QueryUtil.list(q,
16825                                                            getDialect(), start, end);
16826                                    }
16827    
16828                                    cacheResult(list);
16829    
16830                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
16831                                            finderArgs, list);
16832                            }
16833                            catch (Exception e) {
16834                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
16835                                            finderArgs);
16836    
16837                                    throw processException(e);
16838                            }
16839                            finally {
16840                                    closeSession(session);
16841                            }
16842                    }
16843    
16844                    return list;
16845            }
16846    
16847            /**
16848             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
16849             *
16850             * @param resourcePrimKey the resource prim key
16851             * @param indexable the indexable
16852             * @param status the status
16853             * @throws SystemException if a system exception occurred
16854             */
16855            @Override
16856            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
16857                    int status) throws SystemException {
16858                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
16859                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16860                            remove(journalArticle);
16861                    }
16862            }
16863    
16864            /**
16865             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
16866             *
16867             * @param resourcePrimKey the resource prim key
16868             * @param indexable the indexable
16869             * @param status the status
16870             * @return the number of matching journal articles
16871             * @throws SystemException if a system exception occurred
16872             */
16873            @Override
16874            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status)
16875                    throws SystemException {
16876                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
16877    
16878                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
16879    
16880                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16881                                    this);
16882    
16883                    if (count == null) {
16884                            StringBundler query = new StringBundler(4);
16885    
16886                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16887    
16888                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
16889    
16890                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
16891    
16892                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
16893    
16894                            String sql = query.toString();
16895    
16896                            Session session = null;
16897    
16898                            try {
16899                                    session = openSession();
16900    
16901                                    Query q = session.createQuery(sql);
16902    
16903                                    QueryPos qPos = QueryPos.getInstance(q);
16904    
16905                                    qPos.add(resourcePrimKey);
16906    
16907                                    qPos.add(indexable);
16908    
16909                                    qPos.add(status);
16910    
16911                                    count = (Long)q.uniqueResult();
16912    
16913                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16914                            }
16915                            catch (Exception e) {
16916                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16917    
16918                                    throw processException(e);
16919                            }
16920                            finally {
16921                                    closeSession(session);
16922                            }
16923                    }
16924    
16925                    return count.intValue();
16926            }
16927    
16928            /**
16929             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
16930             *
16931             * @param resourcePrimKey the resource prim key
16932             * @param indexable the indexable
16933             * @param statuses the statuses
16934             * @return the number of matching journal articles
16935             * @throws SystemException if a system exception occurred
16936             */
16937            @Override
16938            public int countByR_I_S(long resourcePrimKey, boolean indexable,
16939                    int[] statuses) throws SystemException {
16940                    Object[] finderArgs = new Object[] {
16941                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
16942                            };
16943    
16944                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
16945                                    finderArgs, this);
16946    
16947                    if (count == null) {
16948                            StringBundler query = new StringBundler();
16949    
16950                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16951    
16952                            boolean conjunctionable = false;
16953    
16954                            if (conjunctionable) {
16955                                    query.append(WHERE_AND);
16956                            }
16957    
16958                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
16959    
16960                            conjunctionable = true;
16961    
16962                            if (conjunctionable) {
16963                                    query.append(WHERE_AND);
16964                            }
16965    
16966                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
16967    
16968                            conjunctionable = true;
16969    
16970                            if ((statuses == null) || (statuses.length > 0)) {
16971                                    if (conjunctionable) {
16972                                            query.append(WHERE_AND);
16973                                    }
16974    
16975                                    query.append(StringPool.OPEN_PARENTHESIS);
16976    
16977                                    for (int i = 0; i < statuses.length; i++) {
16978                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
16979    
16980                                            if ((i + 1) < statuses.length) {
16981                                                    query.append(WHERE_OR);
16982                                            }
16983                                    }
16984    
16985                                    query.append(StringPool.CLOSE_PARENTHESIS);
16986    
16987                                    conjunctionable = true;
16988                            }
16989    
16990                            String sql = query.toString();
16991    
16992                            Session session = null;
16993    
16994                            try {
16995                                    session = openSession();
16996    
16997                                    Query q = session.createQuery(sql);
16998    
16999                                    QueryPos qPos = QueryPos.getInstance(q);
17000    
17001                                    qPos.add(resourcePrimKey);
17002    
17003                                    qPos.add(indexable);
17004    
17005                                    if (statuses != null) {
17006                                            qPos.add(statuses);
17007                                    }
17008    
17009                                    count = (Long)q.uniqueResult();
17010    
17011                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
17012                                            finderArgs, count);
17013                            }
17014                            catch (Exception e) {
17015                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
17016                                            finderArgs);
17017    
17018                                    throw processException(e);
17019                            }
17020                            finally {
17021                                    closeSession(session);
17022                            }
17023                    }
17024    
17025                    return count.intValue();
17026            }
17027    
17028            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
17029            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5 = "(" +
17030                    removeConjunction(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2) + ")";
17031            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
17032            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_5 = "(" +
17033                    removeConjunction(_FINDER_COLUMN_R_I_S_INDEXABLE_2) + ")";
17034            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
17035            private static final String _FINDER_COLUMN_R_I_S_STATUS_5 = "(" +
17036                    removeConjunction(_FINDER_COLUMN_R_I_S_STATUS_2) + ")";
17037            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17038                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17039                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17040                            "findByG_F_ST",
17041                            new String[] {
17042                                    Long.class.getName(), Long.class.getName(),
17043                                    Integer.class.getName(),
17044                                    
17045                            Integer.class.getName(), Integer.class.getName(),
17046                                    OrderByComparator.class.getName()
17047                            });
17048            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
17049                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17050                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17051                            JournalArticleImpl.class,
17052                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
17053                            new String[] {
17054                                    Long.class.getName(), Long.class.getName(),
17055                                    Integer.class.getName()
17056                            },
17057                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
17058                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
17059                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
17060                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17061                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17062            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17063                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17064                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
17065                            new String[] {
17066                                    Long.class.getName(), Long.class.getName(),
17067                                    Integer.class.getName()
17068                            });
17069            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17070                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17071                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
17072                            new String[] {
17073                                    Long.class.getName(), Long.class.getName(),
17074                                    Integer.class.getName()
17075                            });
17076    
17077            /**
17078             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
17079             *
17080             * @param groupId the group ID
17081             * @param folderId the folder ID
17082             * @param status the status
17083             * @return the matching journal articles
17084             * @throws SystemException if a system exception occurred
17085             */
17086            @Override
17087            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
17088                    int status) throws SystemException {
17089                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
17090                            QueryUtil.ALL_POS, null);
17091            }
17092    
17093            /**
17094             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
17095             *
17096             * <p>
17097             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17098             * </p>
17099             *
17100             * @param groupId the group ID
17101             * @param folderId the folder ID
17102             * @param status the status
17103             * @param start the lower bound of the range of journal articles
17104             * @param end the upper bound of the range of journal articles (not inclusive)
17105             * @return the range of matching journal articles
17106             * @throws SystemException if a system exception occurred
17107             */
17108            @Override
17109            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
17110                    int status, int start, int end) throws SystemException {
17111                    return findByG_F_ST(groupId, folderId, status, start, end, null);
17112            }
17113    
17114            /**
17115             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
17116             *
17117             * <p>
17118             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17119             * </p>
17120             *
17121             * @param groupId the group ID
17122             * @param folderId the folder ID
17123             * @param status the status
17124             * @param start the lower bound of the range of journal articles
17125             * @param end the upper bound of the range of journal articles (not inclusive)
17126             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17127             * @return the ordered range of matching journal articles
17128             * @throws SystemException if a system exception occurred
17129             */
17130            @Override
17131            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
17132                    int status, int start, int end, OrderByComparator orderByComparator)
17133                    throws SystemException {
17134                    boolean pagination = true;
17135                    FinderPath finderPath = null;
17136                    Object[] finderArgs = null;
17137    
17138                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17139                                    (orderByComparator == null)) {
17140                            pagination = false;
17141                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
17142                            finderArgs = new Object[] { groupId, folderId, status };
17143                    }
17144                    else {
17145                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
17146                            finderArgs = new Object[] {
17147                                            groupId, folderId, status,
17148                                            
17149                                            start, end, orderByComparator
17150                                    };
17151                    }
17152    
17153                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17154                                    finderArgs, this);
17155    
17156                    if ((list != null) && !list.isEmpty()) {
17157                            for (JournalArticle journalArticle : list) {
17158                                    if ((groupId != journalArticle.getGroupId()) ||
17159                                                    (folderId != journalArticle.getFolderId()) ||
17160                                                    (status != journalArticle.getStatus())) {
17161                                            list = null;
17162    
17163                                            break;
17164                                    }
17165                            }
17166                    }
17167    
17168                    if (list == null) {
17169                            StringBundler query = null;
17170    
17171                            if (orderByComparator != null) {
17172                                    query = new StringBundler(5 +
17173                                                    (orderByComparator.getOrderByFields().length * 3));
17174                            }
17175                            else {
17176                                    query = new StringBundler(5);
17177                            }
17178    
17179                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17180    
17181                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
17182    
17183                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
17184    
17185                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
17186    
17187                            if (orderByComparator != null) {
17188                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17189                                            orderByComparator);
17190                            }
17191                            else
17192                             if (pagination) {
17193                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17194                            }
17195    
17196                            String sql = query.toString();
17197    
17198                            Session session = null;
17199    
17200                            try {
17201                                    session = openSession();
17202    
17203                                    Query q = session.createQuery(sql);
17204    
17205                                    QueryPos qPos = QueryPos.getInstance(q);
17206    
17207                                    qPos.add(groupId);
17208    
17209                                    qPos.add(folderId);
17210    
17211                                    qPos.add(status);
17212    
17213                                    if (!pagination) {
17214                                            list = (List<JournalArticle>)QueryUtil.list(q,
17215                                                            getDialect(), start, end, false);
17216    
17217                                            Collections.sort(list);
17218    
17219                                            list = new UnmodifiableList<JournalArticle>(list);
17220                                    }
17221                                    else {
17222                                            list = (List<JournalArticle>)QueryUtil.list(q,
17223                                                            getDialect(), start, end);
17224                                    }
17225    
17226                                    cacheResult(list);
17227    
17228                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17229                            }
17230                            catch (Exception e) {
17231                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17232    
17233                                    throw processException(e);
17234                            }
17235                            finally {
17236                                    closeSession(session);
17237                            }
17238                    }
17239    
17240                    return list;
17241            }
17242    
17243            /**
17244             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17245             *
17246             * @param groupId the group ID
17247             * @param folderId the folder ID
17248             * @param status the status
17249             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17250             * @return the first matching journal article
17251             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17252             * @throws SystemException if a system exception occurred
17253             */
17254            @Override
17255            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
17256                    int status, OrderByComparator orderByComparator)
17257                    throws NoSuchArticleException, SystemException {
17258                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
17259                                    status, orderByComparator);
17260    
17261                    if (journalArticle != null) {
17262                            return journalArticle;
17263                    }
17264    
17265                    StringBundler msg = new StringBundler(8);
17266    
17267                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17268    
17269                    msg.append("groupId=");
17270                    msg.append(groupId);
17271    
17272                    msg.append(", folderId=");
17273                    msg.append(folderId);
17274    
17275                    msg.append(", status=");
17276                    msg.append(status);
17277    
17278                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17279    
17280                    throw new NoSuchArticleException(msg.toString());
17281            }
17282    
17283            /**
17284             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17285             *
17286             * @param groupId the group ID
17287             * @param folderId the folder ID
17288             * @param status the status
17289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17290             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17291             * @throws SystemException if a system exception occurred
17292             */
17293            @Override
17294            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
17295                    int status, OrderByComparator orderByComparator)
17296                    throws SystemException {
17297                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
17298                                    1, orderByComparator);
17299    
17300                    if (!list.isEmpty()) {
17301                            return list.get(0);
17302                    }
17303    
17304                    return null;
17305            }
17306    
17307            /**
17308             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17309             *
17310             * @param groupId the group ID
17311             * @param folderId the folder ID
17312             * @param status the status
17313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17314             * @return the last matching journal article
17315             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17316             * @throws SystemException if a system exception occurred
17317             */
17318            @Override
17319            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
17320                    int status, OrderByComparator orderByComparator)
17321                    throws NoSuchArticleException, SystemException {
17322                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
17323                                    status, orderByComparator);
17324    
17325                    if (journalArticle != null) {
17326                            return journalArticle;
17327                    }
17328    
17329                    StringBundler msg = new StringBundler(8);
17330    
17331                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17332    
17333                    msg.append("groupId=");
17334                    msg.append(groupId);
17335    
17336                    msg.append(", folderId=");
17337                    msg.append(folderId);
17338    
17339                    msg.append(", status=");
17340                    msg.append(status);
17341    
17342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17343    
17344                    throw new NoSuchArticleException(msg.toString());
17345            }
17346    
17347            /**
17348             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17349             *
17350             * @param groupId the group ID
17351             * @param folderId the folder ID
17352             * @param status the status
17353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17354             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17355             * @throws SystemException if a system exception occurred
17356             */
17357            @Override
17358            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
17359                    int status, OrderByComparator orderByComparator)
17360                    throws SystemException {
17361                    int count = countByG_F_ST(groupId, folderId, status);
17362    
17363                    if (count == 0) {
17364                            return null;
17365                    }
17366    
17367                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
17368                                    count - 1, count, orderByComparator);
17369    
17370                    if (!list.isEmpty()) {
17371                            return list.get(0);
17372                    }
17373    
17374                    return null;
17375            }
17376    
17377            /**
17378             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
17379             *
17380             * @param id the primary key of the current journal article
17381             * @param groupId the group ID
17382             * @param folderId the folder ID
17383             * @param status the status
17384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17385             * @return the previous, current, and next journal article
17386             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17387             * @throws SystemException if a system exception occurred
17388             */
17389            @Override
17390            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
17391                    long folderId, int status, OrderByComparator orderByComparator)
17392                    throws NoSuchArticleException, SystemException {
17393                    JournalArticle journalArticle = findByPrimaryKey(id);
17394    
17395                    Session session = null;
17396    
17397                    try {
17398                            session = openSession();
17399    
17400                            JournalArticle[] array = new JournalArticleImpl[3];
17401    
17402                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
17403                                            groupId, folderId, status, orderByComparator, true);
17404    
17405                            array[1] = journalArticle;
17406    
17407                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
17408                                            groupId, folderId, status, orderByComparator, false);
17409    
17410                            return array;
17411                    }
17412                    catch (Exception e) {
17413                            throw processException(e);
17414                    }
17415                    finally {
17416                            closeSession(session);
17417                    }
17418            }
17419    
17420            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
17421                    JournalArticle journalArticle, long groupId, long folderId, int status,
17422                    OrderByComparator orderByComparator, boolean previous) {
17423                    StringBundler query = null;
17424    
17425                    if (orderByComparator != null) {
17426                            query = new StringBundler(6 +
17427                                            (orderByComparator.getOrderByFields().length * 6));
17428                    }
17429                    else {
17430                            query = new StringBundler(3);
17431                    }
17432    
17433                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17434    
17435                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
17436    
17437                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
17438    
17439                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
17440    
17441                    if (orderByComparator != null) {
17442                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17443    
17444                            if (orderByConditionFields.length > 0) {
17445                                    query.append(WHERE_AND);
17446                            }
17447    
17448                            for (int i = 0; i < orderByConditionFields.length; i++) {
17449                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17450                                    query.append(orderByConditionFields[i]);
17451    
17452                                    if ((i + 1) < orderByConditionFields.length) {
17453                                            if (orderByComparator.isAscending() ^ previous) {
17454                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17455                                            }
17456                                            else {
17457                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17458                                            }
17459                                    }
17460                                    else {
17461                                            if (orderByComparator.isAscending() ^ previous) {
17462                                                    query.append(WHERE_GREATER_THAN);
17463                                            }
17464                                            else {
17465                                                    query.append(WHERE_LESSER_THAN);
17466                                            }
17467                                    }
17468                            }
17469    
17470                            query.append(ORDER_BY_CLAUSE);
17471    
17472                            String[] orderByFields = orderByComparator.getOrderByFields();
17473    
17474                            for (int i = 0; i < orderByFields.length; i++) {
17475                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17476                                    query.append(orderByFields[i]);
17477    
17478                                    if ((i + 1) < orderByFields.length) {
17479                                            if (orderByComparator.isAscending() ^ previous) {
17480                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17481                                            }
17482                                            else {
17483                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17484                                            }
17485                                    }
17486                                    else {
17487                                            if (orderByComparator.isAscending() ^ previous) {
17488                                                    query.append(ORDER_BY_ASC);
17489                                            }
17490                                            else {
17491                                                    query.append(ORDER_BY_DESC);
17492                                            }
17493                                    }
17494                            }
17495                    }
17496                    else {
17497                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17498                    }
17499    
17500                    String sql = query.toString();
17501    
17502                    Query q = session.createQuery(sql);
17503    
17504                    q.setFirstResult(0);
17505                    q.setMaxResults(2);
17506    
17507                    QueryPos qPos = QueryPos.getInstance(q);
17508    
17509                    qPos.add(groupId);
17510    
17511                    qPos.add(folderId);
17512    
17513                    qPos.add(status);
17514    
17515                    if (orderByComparator != null) {
17516                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17517    
17518                            for (Object value : values) {
17519                                    qPos.add(value);
17520                            }
17521                    }
17522    
17523                    List<JournalArticle> list = q.list();
17524    
17525                    if (list.size() == 2) {
17526                            return list.get(1);
17527                    }
17528                    else {
17529                            return null;
17530                    }
17531            }
17532    
17533            /**
17534             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
17535             *
17536             * @param groupId the group ID
17537             * @param folderId the folder ID
17538             * @param status the status
17539             * @return the matching journal articles that the user has permission to view
17540             * @throws SystemException if a system exception occurred
17541             */
17542            @Override
17543            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
17544                    int status) throws SystemException {
17545                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
17546                            QueryUtil.ALL_POS, null);
17547            }
17548    
17549            /**
17550             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
17551             *
17552             * <p>
17553             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17554             * </p>
17555             *
17556             * @param groupId the group ID
17557             * @param folderId the folder ID
17558             * @param status the status
17559             * @param start the lower bound of the range of journal articles
17560             * @param end the upper bound of the range of journal articles (not inclusive)
17561             * @return the range of matching journal articles that the user has permission to view
17562             * @throws SystemException if a system exception occurred
17563             */
17564            @Override
17565            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
17566                    int status, int start, int end) throws SystemException {
17567                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
17568            }
17569    
17570            /**
17571             * 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;.
17572             *
17573             * <p>
17574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17575             * </p>
17576             *
17577             * @param groupId the group ID
17578             * @param folderId the folder ID
17579             * @param status the status
17580             * @param start the lower bound of the range of journal articles
17581             * @param end the upper bound of the range of journal articles (not inclusive)
17582             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17583             * @return the ordered range of matching journal articles that the user has permission to view
17584             * @throws SystemException if a system exception occurred
17585             */
17586            @Override
17587            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
17588                    int status, int start, int end, OrderByComparator orderByComparator)
17589                    throws SystemException {
17590                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17591                            return findByG_F_ST(groupId, folderId, status, start, end,
17592                                    orderByComparator);
17593                    }
17594    
17595                    StringBundler query = null;
17596    
17597                    if (orderByComparator != null) {
17598                            query = new StringBundler(5 +
17599                                            (orderByComparator.getOrderByFields().length * 3));
17600                    }
17601                    else {
17602                            query = new StringBundler(5);
17603                    }
17604    
17605                    if (getDB().isSupportsInlineDistinct()) {
17606                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17607                    }
17608                    else {
17609                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17610                    }
17611    
17612                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
17613    
17614                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
17615    
17616                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
17617    
17618                    if (!getDB().isSupportsInlineDistinct()) {
17619                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17620                    }
17621    
17622                    if (orderByComparator != null) {
17623                            if (getDB().isSupportsInlineDistinct()) {
17624                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17625                                            orderByComparator, true);
17626                            }
17627                            else {
17628                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17629                                            orderByComparator, true);
17630                            }
17631                    }
17632                    else {
17633                            if (getDB().isSupportsInlineDistinct()) {
17634                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17635                            }
17636                            else {
17637                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17638                            }
17639                    }
17640    
17641                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17642                                    JournalArticle.class.getName(),
17643                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17644    
17645                    Session session = null;
17646    
17647                    try {
17648                            session = openSession();
17649    
17650                            SQLQuery q = session.createSQLQuery(sql);
17651    
17652                            if (getDB().isSupportsInlineDistinct()) {
17653                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17654                            }
17655                            else {
17656                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17657                            }
17658    
17659                            QueryPos qPos = QueryPos.getInstance(q);
17660    
17661                            qPos.add(groupId);
17662    
17663                            qPos.add(folderId);
17664    
17665                            qPos.add(status);
17666    
17667                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
17668                                    end);
17669                    }
17670                    catch (Exception e) {
17671                            throw processException(e);
17672                    }
17673                    finally {
17674                            closeSession(session);
17675                    }
17676            }
17677    
17678            /**
17679             * 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;.
17680             *
17681             * @param id the primary key of the current journal article
17682             * @param groupId the group ID
17683             * @param folderId the folder ID
17684             * @param status the status
17685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17686             * @return the previous, current, and next journal article
17687             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17688             * @throws SystemException if a system exception occurred
17689             */
17690            @Override
17691            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
17692                    long groupId, long folderId, int status,
17693                    OrderByComparator orderByComparator)
17694                    throws NoSuchArticleException, SystemException {
17695                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17696                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
17697                                    orderByComparator);
17698                    }
17699    
17700                    JournalArticle journalArticle = findByPrimaryKey(id);
17701    
17702                    Session session = null;
17703    
17704                    try {
17705                            session = openSession();
17706    
17707                            JournalArticle[] array = new JournalArticleImpl[3];
17708    
17709                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
17710                                            groupId, folderId, status, orderByComparator, true);
17711    
17712                            array[1] = journalArticle;
17713    
17714                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
17715                                            groupId, folderId, status, orderByComparator, false);
17716    
17717                            return array;
17718                    }
17719                    catch (Exception e) {
17720                            throw processException(e);
17721                    }
17722                    finally {
17723                            closeSession(session);
17724                    }
17725            }
17726    
17727            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
17728                    JournalArticle journalArticle, long groupId, long folderId, int status,
17729                    OrderByComparator orderByComparator, boolean previous) {
17730                    StringBundler query = null;
17731    
17732                    if (orderByComparator != null) {
17733                            query = new StringBundler(6 +
17734                                            (orderByComparator.getOrderByFields().length * 6));
17735                    }
17736                    else {
17737                            query = new StringBundler(3);
17738                    }
17739    
17740                    if (getDB().isSupportsInlineDistinct()) {
17741                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17742                    }
17743                    else {
17744                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17745                    }
17746    
17747                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
17748    
17749                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
17750    
17751                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
17752    
17753                    if (!getDB().isSupportsInlineDistinct()) {
17754                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17755                    }
17756    
17757                    if (orderByComparator != null) {
17758                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17759    
17760                            if (orderByConditionFields.length > 0) {
17761                                    query.append(WHERE_AND);
17762                            }
17763    
17764                            for (int i = 0; i < orderByConditionFields.length; i++) {
17765                                    if (getDB().isSupportsInlineDistinct()) {
17766                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17767                                    }
17768                                    else {
17769                                            query.append(_ORDER_BY_ENTITY_TABLE);
17770                                    }
17771    
17772                                    query.append(orderByConditionFields[i]);
17773    
17774                                    if ((i + 1) < orderByConditionFields.length) {
17775                                            if (orderByComparator.isAscending() ^ previous) {
17776                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17777                                            }
17778                                            else {
17779                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17780                                            }
17781                                    }
17782                                    else {
17783                                            if (orderByComparator.isAscending() ^ previous) {
17784                                                    query.append(WHERE_GREATER_THAN);
17785                                            }
17786                                            else {
17787                                                    query.append(WHERE_LESSER_THAN);
17788                                            }
17789                                    }
17790                            }
17791    
17792                            query.append(ORDER_BY_CLAUSE);
17793    
17794                            String[] orderByFields = orderByComparator.getOrderByFields();
17795    
17796                            for (int i = 0; i < orderByFields.length; i++) {
17797                                    if (getDB().isSupportsInlineDistinct()) {
17798                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17799                                    }
17800                                    else {
17801                                            query.append(_ORDER_BY_ENTITY_TABLE);
17802                                    }
17803    
17804                                    query.append(orderByFields[i]);
17805    
17806                                    if ((i + 1) < orderByFields.length) {
17807                                            if (orderByComparator.isAscending() ^ previous) {
17808                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17809                                            }
17810                                            else {
17811                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17812                                            }
17813                                    }
17814                                    else {
17815                                            if (orderByComparator.isAscending() ^ previous) {
17816                                                    query.append(ORDER_BY_ASC);
17817                                            }
17818                                            else {
17819                                                    query.append(ORDER_BY_DESC);
17820                                            }
17821                                    }
17822                            }
17823                    }
17824                    else {
17825                            if (getDB().isSupportsInlineDistinct()) {
17826                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17827                            }
17828                            else {
17829                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17830                            }
17831                    }
17832    
17833                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17834                                    JournalArticle.class.getName(),
17835                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17836    
17837                    SQLQuery q = session.createSQLQuery(sql);
17838    
17839                    q.setFirstResult(0);
17840                    q.setMaxResults(2);
17841    
17842                    if (getDB().isSupportsInlineDistinct()) {
17843                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17844                    }
17845                    else {
17846                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17847                    }
17848    
17849                    QueryPos qPos = QueryPos.getInstance(q);
17850    
17851                    qPos.add(groupId);
17852    
17853                    qPos.add(folderId);
17854    
17855                    qPos.add(status);
17856    
17857                    if (orderByComparator != null) {
17858                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17859    
17860                            for (Object value : values) {
17861                                    qPos.add(value);
17862                            }
17863                    }
17864    
17865                    List<JournalArticle> list = q.list();
17866    
17867                    if (list.size() == 2) {
17868                            return list.get(1);
17869                    }
17870                    else {
17871                            return null;
17872                    }
17873            }
17874    
17875            /**
17876             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
17877             *
17878             * @param groupId the group ID
17879             * @param folderId the folder ID
17880             * @param statuses the statuses
17881             * @return the matching journal articles that the user has permission to view
17882             * @throws SystemException if a system exception occurred
17883             */
17884            @Override
17885            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
17886                    int[] statuses) throws SystemException {
17887                    return filterFindByG_F_ST(groupId, folderId, statuses,
17888                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17889            }
17890    
17891            /**
17892             * 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;.
17893             *
17894             * <p>
17895             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17896             * </p>
17897             *
17898             * @param groupId the group ID
17899             * @param folderId the folder ID
17900             * @param statuses the statuses
17901             * @param start the lower bound of the range of journal articles
17902             * @param end the upper bound of the range of journal articles (not inclusive)
17903             * @return the range of matching journal articles that the user has permission to view
17904             * @throws SystemException if a system exception occurred
17905             */
17906            @Override
17907            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
17908                    int[] statuses, int start, int end) throws SystemException {
17909                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
17910            }
17911    
17912            /**
17913             * 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;.
17914             *
17915             * <p>
17916             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17917             * </p>
17918             *
17919             * @param groupId the group ID
17920             * @param folderId the folder ID
17921             * @param statuses the statuses
17922             * @param start the lower bound of the range of journal articles
17923             * @param end the upper bound of the range of journal articles (not inclusive)
17924             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17925             * @return the ordered range of matching journal articles that the user has permission to view
17926             * @throws SystemException if a system exception occurred
17927             */
17928            @Override
17929            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
17930                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
17931                    throws SystemException {
17932                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17933                            return findByG_F_ST(groupId, folderId, statuses, start, end,
17934                                    orderByComparator);
17935                    }
17936    
17937                    StringBundler query = new StringBundler();
17938    
17939                    if (getDB().isSupportsInlineDistinct()) {
17940                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17941                    }
17942                    else {
17943                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17944                    }
17945    
17946                    boolean conjunctionable = false;
17947    
17948                    if (conjunctionable) {
17949                            query.append(WHERE_AND);
17950                    }
17951    
17952                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
17953    
17954                    conjunctionable = true;
17955    
17956                    if (conjunctionable) {
17957                            query.append(WHERE_AND);
17958                    }
17959    
17960                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
17961    
17962                    conjunctionable = true;
17963    
17964                    if ((statuses == null) || (statuses.length > 0)) {
17965                            if (conjunctionable) {
17966                                    query.append(WHERE_AND);
17967                            }
17968    
17969                            query.append(StringPool.OPEN_PARENTHESIS);
17970    
17971                            for (int i = 0; i < statuses.length; i++) {
17972                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
17973    
17974                                    if ((i + 1) < statuses.length) {
17975                                            query.append(WHERE_OR);
17976                                    }
17977                            }
17978    
17979                            query.append(StringPool.CLOSE_PARENTHESIS);
17980    
17981                            conjunctionable = true;
17982                    }
17983    
17984                    if (!getDB().isSupportsInlineDistinct()) {
17985                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17986                    }
17987    
17988                    if (orderByComparator != null) {
17989                            if (getDB().isSupportsInlineDistinct()) {
17990                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17991                                            orderByComparator, true);
17992                            }
17993                            else {
17994                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17995                                            orderByComparator, true);
17996                            }
17997                    }
17998                    else {
17999                            if (getDB().isSupportsInlineDistinct()) {
18000                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18001                            }
18002                            else {
18003                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18004                            }
18005                    }
18006    
18007                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18008                                    JournalArticle.class.getName(),
18009                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18010    
18011                    Session session = null;
18012    
18013                    try {
18014                            session = openSession();
18015    
18016                            SQLQuery q = session.createSQLQuery(sql);
18017    
18018                            if (getDB().isSupportsInlineDistinct()) {
18019                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18020                            }
18021                            else {
18022                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18023                            }
18024    
18025                            QueryPos qPos = QueryPos.getInstance(q);
18026    
18027                            qPos.add(groupId);
18028    
18029                            qPos.add(folderId);
18030    
18031                            if (statuses != null) {
18032                                    qPos.add(statuses);
18033                            }
18034    
18035                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18036                                    end);
18037                    }
18038                    catch (Exception e) {
18039                            throw processException(e);
18040                    }
18041                    finally {
18042                            closeSession(session);
18043                    }
18044            }
18045    
18046            /**
18047             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18048             *
18049             * <p>
18050             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18051             * </p>
18052             *
18053             * @param groupId the group ID
18054             * @param folderId the folder ID
18055             * @param statuses the statuses
18056             * @return the matching journal articles
18057             * @throws SystemException if a system exception occurred
18058             */
18059            @Override
18060            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
18061                    int[] statuses) throws SystemException {
18062                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
18063                            QueryUtil.ALL_POS, null);
18064            }
18065    
18066            /**
18067             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18068             *
18069             * <p>
18070             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18071             * </p>
18072             *
18073             * @param groupId the group ID
18074             * @param folderId the folder ID
18075             * @param statuses the statuses
18076             * @param start the lower bound of the range of journal articles
18077             * @param end the upper bound of the range of journal articles (not inclusive)
18078             * @return the range of matching journal articles
18079             * @throws SystemException if a system exception occurred
18080             */
18081            @Override
18082            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
18083                    int[] statuses, int start, int end) throws SystemException {
18084                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
18085            }
18086    
18087            /**
18088             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18089             *
18090             * <p>
18091             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18092             * </p>
18093             *
18094             * @param groupId the group ID
18095             * @param folderId the folder ID
18096             * @param statuses the statuses
18097             * @param start the lower bound of the range of journal articles
18098             * @param end the upper bound of the range of journal articles (not inclusive)
18099             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18100             * @return the ordered range of matching journal articles
18101             * @throws SystemException if a system exception occurred
18102             */
18103            @Override
18104            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
18105                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
18106                    throws SystemException {
18107                    if ((statuses != null) && (statuses.length == 1)) {
18108                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
18109                                    orderByComparator);
18110                    }
18111    
18112                    boolean pagination = true;
18113                    Object[] finderArgs = null;
18114    
18115                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18116                                    (orderByComparator == null)) {
18117                            pagination = false;
18118                            finderArgs = new Object[] {
18119                                            groupId, folderId, StringUtil.merge(statuses)
18120                                    };
18121                    }
18122                    else {
18123                            finderArgs = new Object[] {
18124                                            groupId, folderId, StringUtil.merge(statuses),
18125                                            
18126                                            start, end, orderByComparator
18127                                    };
18128                    }
18129    
18130                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
18131                                    finderArgs, this);
18132    
18133                    if ((list != null) && !list.isEmpty()) {
18134                            for (JournalArticle journalArticle : list) {
18135                                    if ((groupId != journalArticle.getGroupId()) ||
18136                                                    (folderId != journalArticle.getFolderId()) ||
18137                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
18138                                            list = null;
18139    
18140                                            break;
18141                                    }
18142                            }
18143                    }
18144    
18145                    if (list == null) {
18146                            StringBundler query = new StringBundler();
18147    
18148                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18149    
18150                            boolean conjunctionable = false;
18151    
18152                            if (conjunctionable) {
18153                                    query.append(WHERE_AND);
18154                            }
18155    
18156                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
18157    
18158                            conjunctionable = true;
18159    
18160                            if (conjunctionable) {
18161                                    query.append(WHERE_AND);
18162                            }
18163    
18164                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
18165    
18166                            conjunctionable = true;
18167    
18168                            if ((statuses == null) || (statuses.length > 0)) {
18169                                    if (conjunctionable) {
18170                                            query.append(WHERE_AND);
18171                                    }
18172    
18173                                    query.append(StringPool.OPEN_PARENTHESIS);
18174    
18175                                    for (int i = 0; i < statuses.length; i++) {
18176                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
18177    
18178                                            if ((i + 1) < statuses.length) {
18179                                                    query.append(WHERE_OR);
18180                                            }
18181                                    }
18182    
18183                                    query.append(StringPool.CLOSE_PARENTHESIS);
18184    
18185                                    conjunctionable = true;
18186                            }
18187    
18188                            if (orderByComparator != null) {
18189                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18190                                            orderByComparator);
18191                            }
18192                            else
18193                             if (pagination) {
18194                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18195                            }
18196    
18197                            String sql = query.toString();
18198    
18199                            Session session = null;
18200    
18201                            try {
18202                                    session = openSession();
18203    
18204                                    Query q = session.createQuery(sql);
18205    
18206                                    QueryPos qPos = QueryPos.getInstance(q);
18207    
18208                                    qPos.add(groupId);
18209    
18210                                    qPos.add(folderId);
18211    
18212                                    if (statuses != null) {
18213                                            qPos.add(statuses);
18214                                    }
18215    
18216                                    if (!pagination) {
18217                                            list = (List<JournalArticle>)QueryUtil.list(q,
18218                                                            getDialect(), start, end, false);
18219    
18220                                            Collections.sort(list);
18221    
18222                                            list = new UnmodifiableList<JournalArticle>(list);
18223                                    }
18224                                    else {
18225                                            list = (List<JournalArticle>)QueryUtil.list(q,
18226                                                            getDialect(), start, end);
18227                                    }
18228    
18229                                    cacheResult(list);
18230    
18231                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
18232                                            finderArgs, list);
18233                            }
18234                            catch (Exception e) {
18235                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
18236                                            finderArgs);
18237    
18238                                    throw processException(e);
18239                            }
18240                            finally {
18241                                    closeSession(session);
18242                            }
18243                    }
18244    
18245                    return list;
18246            }
18247    
18248            /**
18249             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
18250             *
18251             * @param groupId the group ID
18252             * @param folderId the folder ID
18253             * @param status the status
18254             * @throws SystemException if a system exception occurred
18255             */
18256            @Override
18257            public void removeByG_F_ST(long groupId, long folderId, int status)
18258                    throws SystemException {
18259                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
18260                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18261                            remove(journalArticle);
18262                    }
18263            }
18264    
18265            /**
18266             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
18267             *
18268             * @param groupId the group ID
18269             * @param folderId the folder ID
18270             * @param status the status
18271             * @return the number of matching journal articles
18272             * @throws SystemException if a system exception occurred
18273             */
18274            @Override
18275            public int countByG_F_ST(long groupId, long folderId, int status)
18276                    throws SystemException {
18277                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
18278    
18279                    Object[] finderArgs = new Object[] { groupId, folderId, status };
18280    
18281                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18282                                    this);
18283    
18284                    if (count == null) {
18285                            StringBundler query = new StringBundler(4);
18286    
18287                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18288    
18289                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
18290    
18291                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
18292    
18293                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
18294    
18295                            String sql = query.toString();
18296    
18297                            Session session = null;
18298    
18299                            try {
18300                                    session = openSession();
18301    
18302                                    Query q = session.createQuery(sql);
18303    
18304                                    QueryPos qPos = QueryPos.getInstance(q);
18305    
18306                                    qPos.add(groupId);
18307    
18308                                    qPos.add(folderId);
18309    
18310                                    qPos.add(status);
18311    
18312                                    count = (Long)q.uniqueResult();
18313    
18314                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18315                            }
18316                            catch (Exception e) {
18317                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18318    
18319                                    throw processException(e);
18320                            }
18321                            finally {
18322                                    closeSession(session);
18323                            }
18324                    }
18325    
18326                    return count.intValue();
18327            }
18328    
18329            /**
18330             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
18331             *
18332             * @param groupId the group ID
18333             * @param folderId the folder ID
18334             * @param statuses the statuses
18335             * @return the number of matching journal articles
18336             * @throws SystemException if a system exception occurred
18337             */
18338            @Override
18339            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
18340                    throws SystemException {
18341                    Object[] finderArgs = new Object[] {
18342                                    groupId, folderId, StringUtil.merge(statuses)
18343                            };
18344    
18345                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
18346                                    finderArgs, this);
18347    
18348                    if (count == null) {
18349                            StringBundler query = new StringBundler();
18350    
18351                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18352    
18353                            boolean conjunctionable = false;
18354    
18355                            if (conjunctionable) {
18356                                    query.append(WHERE_AND);
18357                            }
18358    
18359                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
18360    
18361                            conjunctionable = true;
18362    
18363                            if (conjunctionable) {
18364                                    query.append(WHERE_AND);
18365                            }
18366    
18367                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
18368    
18369                            conjunctionable = true;
18370    
18371                            if ((statuses == null) || (statuses.length > 0)) {
18372                                    if (conjunctionable) {
18373                                            query.append(WHERE_AND);
18374                                    }
18375    
18376                                    query.append(StringPool.OPEN_PARENTHESIS);
18377    
18378                                    for (int i = 0; i < statuses.length; i++) {
18379                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
18380    
18381                                            if ((i + 1) < statuses.length) {
18382                                                    query.append(WHERE_OR);
18383                                            }
18384                                    }
18385    
18386                                    query.append(StringPool.CLOSE_PARENTHESIS);
18387    
18388                                    conjunctionable = true;
18389                            }
18390    
18391                            String sql = query.toString();
18392    
18393                            Session session = null;
18394    
18395                            try {
18396                                    session = openSession();
18397    
18398                                    Query q = session.createQuery(sql);
18399    
18400                                    QueryPos qPos = QueryPos.getInstance(q);
18401    
18402                                    qPos.add(groupId);
18403    
18404                                    qPos.add(folderId);
18405    
18406                                    if (statuses != null) {
18407                                            qPos.add(statuses);
18408                                    }
18409    
18410                                    count = (Long)q.uniqueResult();
18411    
18412                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
18413                                            finderArgs, count);
18414                            }
18415                            catch (Exception e) {
18416                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
18417                                            finderArgs);
18418    
18419                                    throw processException(e);
18420                            }
18421                            finally {
18422                                    closeSession(session);
18423                            }
18424                    }
18425    
18426                    return count.intValue();
18427            }
18428    
18429            /**
18430             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
18431             *
18432             * @param groupId the group ID
18433             * @param folderId the folder ID
18434             * @param status the status
18435             * @return the number of matching journal articles that the user has permission to view
18436             * @throws SystemException if a system exception occurred
18437             */
18438            @Override
18439            public int filterCountByG_F_ST(long groupId, long folderId, int status)
18440                    throws SystemException {
18441                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18442                            return countByG_F_ST(groupId, folderId, status);
18443                    }
18444    
18445                    StringBundler query = new StringBundler(4);
18446    
18447                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18448    
18449                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
18450    
18451                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
18452    
18453                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
18454    
18455                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18456                                    JournalArticle.class.getName(),
18457                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18458    
18459                    Session session = null;
18460    
18461                    try {
18462                            session = openSession();
18463    
18464                            SQLQuery q = session.createSQLQuery(sql);
18465    
18466                            q.addScalar(COUNT_COLUMN_NAME,
18467                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18468    
18469                            QueryPos qPos = QueryPos.getInstance(q);
18470    
18471                            qPos.add(groupId);
18472    
18473                            qPos.add(folderId);
18474    
18475                            qPos.add(status);
18476    
18477                            Long count = (Long)q.uniqueResult();
18478    
18479                            return count.intValue();
18480                    }
18481                    catch (Exception e) {
18482                            throw processException(e);
18483                    }
18484                    finally {
18485                            closeSession(session);
18486                    }
18487            }
18488    
18489            /**
18490             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
18491             *
18492             * @param groupId the group ID
18493             * @param folderId the folder ID
18494             * @param statuses the statuses
18495             * @return the number of matching journal articles that the user has permission to view
18496             * @throws SystemException if a system exception occurred
18497             */
18498            @Override
18499            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
18500                    throws SystemException {
18501                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18502                            return countByG_F_ST(groupId, folderId, statuses);
18503                    }
18504    
18505                    StringBundler query = new StringBundler();
18506    
18507                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18508    
18509                    boolean conjunctionable = false;
18510    
18511                    if (conjunctionable) {
18512                            query.append(WHERE_AND);
18513                    }
18514    
18515                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
18516    
18517                    conjunctionable = true;
18518    
18519                    if (conjunctionable) {
18520                            query.append(WHERE_AND);
18521                    }
18522    
18523                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
18524    
18525                    conjunctionable = true;
18526    
18527                    if ((statuses == null) || (statuses.length > 0)) {
18528                            if (conjunctionable) {
18529                                    query.append(WHERE_AND);
18530                            }
18531    
18532                            query.append(StringPool.OPEN_PARENTHESIS);
18533    
18534                            for (int i = 0; i < statuses.length; i++) {
18535                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
18536    
18537                                    if ((i + 1) < statuses.length) {
18538                                            query.append(WHERE_OR);
18539                                    }
18540                            }
18541    
18542                            query.append(StringPool.CLOSE_PARENTHESIS);
18543    
18544                            conjunctionable = true;
18545                    }
18546    
18547                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18548                                    JournalArticle.class.getName(),
18549                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18550    
18551                    Session session = null;
18552    
18553                    try {
18554                            session = openSession();
18555    
18556                            SQLQuery q = session.createSQLQuery(sql);
18557    
18558                            q.addScalar(COUNT_COLUMN_NAME,
18559                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18560    
18561                            QueryPos qPos = QueryPos.getInstance(q);
18562    
18563                            qPos.add(groupId);
18564    
18565                            qPos.add(folderId);
18566    
18567                            if (statuses != null) {
18568                                    qPos.add(statuses);
18569                            }
18570    
18571                            Long count = (Long)q.uniqueResult();
18572    
18573                            return count.intValue();
18574                    }
18575                    catch (Exception e) {
18576                            throw processException(e);
18577                    }
18578                    finally {
18579                            closeSession(session);
18580                    }
18581            }
18582    
18583            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
18584            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
18585                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
18586            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
18587            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
18588                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
18589            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
18590            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
18591                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
18592            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18593                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18594                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18595                            "findByG_C_C",
18596                            new String[] {
18597                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
18598                                    
18599                            Integer.class.getName(), Integer.class.getName(),
18600                                    OrderByComparator.class.getName()
18601                            });
18602            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18603                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18604                            JournalArticleImpl.class,
18605                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
18606                            new String[] {
18607                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18608                            },
18609                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18610                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18611                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
18612                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18613                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18614            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18615                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18616                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
18617                            new String[] {
18618                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18619                            });
18620    
18621            /**
18622             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18623             *
18624             * @param groupId the group ID
18625             * @param classNameId the class name ID
18626             * @param classPK the class p k
18627             * @return the matching journal articles
18628             * @throws SystemException if a system exception occurred
18629             */
18630            @Override
18631            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
18632                    long classPK) throws SystemException {
18633                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
18634                            QueryUtil.ALL_POS, null);
18635            }
18636    
18637            /**
18638             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18639             *
18640             * <p>
18641             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18642             * </p>
18643             *
18644             * @param groupId the group ID
18645             * @param classNameId the class name ID
18646             * @param classPK the class p k
18647             * @param start the lower bound of the range of journal articles
18648             * @param end the upper bound of the range of journal articles (not inclusive)
18649             * @return the range of matching journal articles
18650             * @throws SystemException if a system exception occurred
18651             */
18652            @Override
18653            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
18654                    long classPK, int start, int end) throws SystemException {
18655                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
18656            }
18657    
18658            /**
18659             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18660             *
18661             * <p>
18662             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18663             * </p>
18664             *
18665             * @param groupId the group ID
18666             * @param classNameId the class name ID
18667             * @param classPK the class p k
18668             * @param start the lower bound of the range of journal articles
18669             * @param end the upper bound of the range of journal articles (not inclusive)
18670             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18671             * @return the ordered range of matching journal articles
18672             * @throws SystemException if a system exception occurred
18673             */
18674            @Override
18675            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
18676                    long classPK, int start, int end, OrderByComparator orderByComparator)
18677                    throws SystemException {
18678                    boolean pagination = true;
18679                    FinderPath finderPath = null;
18680                    Object[] finderArgs = null;
18681    
18682                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18683                                    (orderByComparator == null)) {
18684                            pagination = false;
18685                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
18686                            finderArgs = new Object[] { groupId, classNameId, classPK };
18687                    }
18688                    else {
18689                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
18690                            finderArgs = new Object[] {
18691                                            groupId, classNameId, classPK,
18692                                            
18693                                            start, end, orderByComparator
18694                                    };
18695                    }
18696    
18697                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18698                                    finderArgs, this);
18699    
18700                    if ((list != null) && !list.isEmpty()) {
18701                            for (JournalArticle journalArticle : list) {
18702                                    if ((groupId != journalArticle.getGroupId()) ||
18703                                                    (classNameId != journalArticle.getClassNameId()) ||
18704                                                    (classPK != journalArticle.getClassPK())) {
18705                                            list = null;
18706    
18707                                            break;
18708                                    }
18709                            }
18710                    }
18711    
18712                    if (list == null) {
18713                            StringBundler query = null;
18714    
18715                            if (orderByComparator != null) {
18716                                    query = new StringBundler(5 +
18717                                                    (orderByComparator.getOrderByFields().length * 3));
18718                            }
18719                            else {
18720                                    query = new StringBundler(5);
18721                            }
18722    
18723                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18724    
18725                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
18726    
18727                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
18728    
18729                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
18730    
18731                            if (orderByComparator != null) {
18732                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18733                                            orderByComparator);
18734                            }
18735                            else
18736                             if (pagination) {
18737                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18738                            }
18739    
18740                            String sql = query.toString();
18741    
18742                            Session session = null;
18743    
18744                            try {
18745                                    session = openSession();
18746    
18747                                    Query q = session.createQuery(sql);
18748    
18749                                    QueryPos qPos = QueryPos.getInstance(q);
18750    
18751                                    qPos.add(groupId);
18752    
18753                                    qPos.add(classNameId);
18754    
18755                                    qPos.add(classPK);
18756    
18757                                    if (!pagination) {
18758                                            list = (List<JournalArticle>)QueryUtil.list(q,
18759                                                            getDialect(), start, end, false);
18760    
18761                                            Collections.sort(list);
18762    
18763                                            list = new UnmodifiableList<JournalArticle>(list);
18764                                    }
18765                                    else {
18766                                            list = (List<JournalArticle>)QueryUtil.list(q,
18767                                                            getDialect(), start, end);
18768                                    }
18769    
18770                                    cacheResult(list);
18771    
18772                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18773                            }
18774                            catch (Exception e) {
18775                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18776    
18777                                    throw processException(e);
18778                            }
18779                            finally {
18780                                    closeSession(session);
18781                            }
18782                    }
18783    
18784                    return list;
18785            }
18786    
18787            /**
18788             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18789             *
18790             * @param groupId the group ID
18791             * @param classNameId the class name ID
18792             * @param classPK the class p k
18793             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18794             * @return the first matching journal article
18795             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18796             * @throws SystemException if a system exception occurred
18797             */
18798            @Override
18799            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
18800                    long classPK, OrderByComparator orderByComparator)
18801                    throws NoSuchArticleException, SystemException {
18802                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
18803                                    classNameId, classPK, orderByComparator);
18804    
18805                    if (journalArticle != null) {
18806                            return journalArticle;
18807                    }
18808    
18809                    StringBundler msg = new StringBundler(8);
18810    
18811                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18812    
18813                    msg.append("groupId=");
18814                    msg.append(groupId);
18815    
18816                    msg.append(", classNameId=");
18817                    msg.append(classNameId);
18818    
18819                    msg.append(", classPK=");
18820                    msg.append(classPK);
18821    
18822                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18823    
18824                    throw new NoSuchArticleException(msg.toString());
18825            }
18826    
18827            /**
18828             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18829             *
18830             * @param groupId the group ID
18831             * @param classNameId the class name ID
18832             * @param classPK the class p k
18833             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18834             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18835             * @throws SystemException if a system exception occurred
18836             */
18837            @Override
18838            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
18839                    long classPK, OrderByComparator orderByComparator)
18840                    throws SystemException {
18841                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
18842                                    0, 1, orderByComparator);
18843    
18844                    if (!list.isEmpty()) {
18845                            return list.get(0);
18846                    }
18847    
18848                    return null;
18849            }
18850    
18851            /**
18852             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18853             *
18854             * @param groupId the group ID
18855             * @param classNameId the class name ID
18856             * @param classPK the class p k
18857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18858             * @return the last matching journal article
18859             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18860             * @throws SystemException if a system exception occurred
18861             */
18862            @Override
18863            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
18864                    long classPK, OrderByComparator orderByComparator)
18865                    throws NoSuchArticleException, SystemException {
18866                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
18867                                    classPK, orderByComparator);
18868    
18869                    if (journalArticle != null) {
18870                            return journalArticle;
18871                    }
18872    
18873                    StringBundler msg = new StringBundler(8);
18874    
18875                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18876    
18877                    msg.append("groupId=");
18878                    msg.append(groupId);
18879    
18880                    msg.append(", classNameId=");
18881                    msg.append(classNameId);
18882    
18883                    msg.append(", classPK=");
18884                    msg.append(classPK);
18885    
18886                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18887    
18888                    throw new NoSuchArticleException(msg.toString());
18889            }
18890    
18891            /**
18892             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18893             *
18894             * @param groupId the group ID
18895             * @param classNameId the class name ID
18896             * @param classPK the class p k
18897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18898             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18899             * @throws SystemException if a system exception occurred
18900             */
18901            @Override
18902            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
18903                    long classPK, OrderByComparator orderByComparator)
18904                    throws SystemException {
18905                    int count = countByG_C_C(groupId, classNameId, classPK);
18906    
18907                    if (count == 0) {
18908                            return null;
18909                    }
18910    
18911                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
18912                                    count - 1, count, orderByComparator);
18913    
18914                    if (!list.isEmpty()) {
18915                            return list.get(0);
18916                    }
18917    
18918                    return null;
18919            }
18920    
18921            /**
18922             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18923             *
18924             * @param id the primary key of the current journal article
18925             * @param groupId the group ID
18926             * @param classNameId the class name ID
18927             * @param classPK the class p k
18928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18929             * @return the previous, current, and next journal article
18930             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18931             * @throws SystemException if a system exception occurred
18932             */
18933            @Override
18934            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
18935                    long classNameId, long classPK, OrderByComparator orderByComparator)
18936                    throws NoSuchArticleException, SystemException {
18937                    JournalArticle journalArticle = findByPrimaryKey(id);
18938    
18939                    Session session = null;
18940    
18941                    try {
18942                            session = openSession();
18943    
18944                            JournalArticle[] array = new JournalArticleImpl[3];
18945    
18946                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
18947                                            classNameId, classPK, orderByComparator, true);
18948    
18949                            array[1] = journalArticle;
18950    
18951                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
18952                                            classNameId, classPK, orderByComparator, false);
18953    
18954                            return array;
18955                    }
18956                    catch (Exception e) {
18957                            throw processException(e);
18958                    }
18959                    finally {
18960                            closeSession(session);
18961                    }
18962            }
18963    
18964            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
18965                    JournalArticle journalArticle, long groupId, long classNameId,
18966                    long classPK, OrderByComparator orderByComparator, boolean previous) {
18967                    StringBundler query = null;
18968    
18969                    if (orderByComparator != null) {
18970                            query = new StringBundler(6 +
18971                                            (orderByComparator.getOrderByFields().length * 6));
18972                    }
18973                    else {
18974                            query = new StringBundler(3);
18975                    }
18976    
18977                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18978    
18979                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
18980    
18981                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
18982    
18983                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
18984    
18985                    if (orderByComparator != null) {
18986                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18987    
18988                            if (orderByConditionFields.length > 0) {
18989                                    query.append(WHERE_AND);
18990                            }
18991    
18992                            for (int i = 0; i < orderByConditionFields.length; i++) {
18993                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18994                                    query.append(orderByConditionFields[i]);
18995    
18996                                    if ((i + 1) < orderByConditionFields.length) {
18997                                            if (orderByComparator.isAscending() ^ previous) {
18998                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18999                                            }
19000                                            else {
19001                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19002                                            }
19003                                    }
19004                                    else {
19005                                            if (orderByComparator.isAscending() ^ previous) {
19006                                                    query.append(WHERE_GREATER_THAN);
19007                                            }
19008                                            else {
19009                                                    query.append(WHERE_LESSER_THAN);
19010                                            }
19011                                    }
19012                            }
19013    
19014                            query.append(ORDER_BY_CLAUSE);
19015    
19016                            String[] orderByFields = orderByComparator.getOrderByFields();
19017    
19018                            for (int i = 0; i < orderByFields.length; i++) {
19019                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19020                                    query.append(orderByFields[i]);
19021    
19022                                    if ((i + 1) < orderByFields.length) {
19023                                            if (orderByComparator.isAscending() ^ previous) {
19024                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19025                                            }
19026                                            else {
19027                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19028                                            }
19029                                    }
19030                                    else {
19031                                            if (orderByComparator.isAscending() ^ previous) {
19032                                                    query.append(ORDER_BY_ASC);
19033                                            }
19034                                            else {
19035                                                    query.append(ORDER_BY_DESC);
19036                                            }
19037                                    }
19038                            }
19039                    }
19040                    else {
19041                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19042                    }
19043    
19044                    String sql = query.toString();
19045    
19046                    Query q = session.createQuery(sql);
19047    
19048                    q.setFirstResult(0);
19049                    q.setMaxResults(2);
19050    
19051                    QueryPos qPos = QueryPos.getInstance(q);
19052    
19053                    qPos.add(groupId);
19054    
19055                    qPos.add(classNameId);
19056    
19057                    qPos.add(classPK);
19058    
19059                    if (orderByComparator != null) {
19060                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19061    
19062                            for (Object value : values) {
19063                                    qPos.add(value);
19064                            }
19065                    }
19066    
19067                    List<JournalArticle> list = q.list();
19068    
19069                    if (list.size() == 2) {
19070                            return list.get(1);
19071                    }
19072                    else {
19073                            return null;
19074                    }
19075            }
19076    
19077            /**
19078             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19079             *
19080             * @param groupId the group ID
19081             * @param classNameId the class name ID
19082             * @param classPK the class p k
19083             * @return the matching journal articles that the user has permission to view
19084             * @throws SystemException if a system exception occurred
19085             */
19086            @Override
19087            public List<JournalArticle> filterFindByG_C_C(long groupId,
19088                    long classNameId, long classPK) throws SystemException {
19089                    return filterFindByG_C_C(groupId, classNameId, classPK,
19090                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19091            }
19092    
19093            /**
19094             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19095             *
19096             * <p>
19097             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19098             * </p>
19099             *
19100             * @param groupId the group ID
19101             * @param classNameId the class name ID
19102             * @param classPK the class p k
19103             * @param start the lower bound of the range of journal articles
19104             * @param end the upper bound of the range of journal articles (not inclusive)
19105             * @return the range of matching journal articles that the user has permission to view
19106             * @throws SystemException if a system exception occurred
19107             */
19108            @Override
19109            public List<JournalArticle> filterFindByG_C_C(long groupId,
19110                    long classNameId, long classPK, int start, int end)
19111                    throws SystemException {
19112                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
19113            }
19114    
19115            /**
19116             * 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;.
19117             *
19118             * <p>
19119             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19120             * </p>
19121             *
19122             * @param groupId the group ID
19123             * @param classNameId the class name ID
19124             * @param classPK the class p k
19125             * @param start the lower bound of the range of journal articles
19126             * @param end the upper bound of the range of journal articles (not inclusive)
19127             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19128             * @return the ordered range of matching journal articles that the user has permission to view
19129             * @throws SystemException if a system exception occurred
19130             */
19131            @Override
19132            public List<JournalArticle> filterFindByG_C_C(long groupId,
19133                    long classNameId, long classPK, int start, int end,
19134                    OrderByComparator orderByComparator) throws SystemException {
19135                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19136                            return findByG_C_C(groupId, classNameId, classPK, start, end,
19137                                    orderByComparator);
19138                    }
19139    
19140                    StringBundler query = null;
19141    
19142                    if (orderByComparator != null) {
19143                            query = new StringBundler(5 +
19144                                            (orderByComparator.getOrderByFields().length * 3));
19145                    }
19146                    else {
19147                            query = new StringBundler(5);
19148                    }
19149    
19150                    if (getDB().isSupportsInlineDistinct()) {
19151                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19152                    }
19153                    else {
19154                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19155                    }
19156    
19157                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19158    
19159                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19160    
19161                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19162    
19163                    if (!getDB().isSupportsInlineDistinct()) {
19164                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19165                    }
19166    
19167                    if (orderByComparator != null) {
19168                            if (getDB().isSupportsInlineDistinct()) {
19169                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19170                                            orderByComparator, true);
19171                            }
19172                            else {
19173                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19174                                            orderByComparator, true);
19175                            }
19176                    }
19177                    else {
19178                            if (getDB().isSupportsInlineDistinct()) {
19179                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19180                            }
19181                            else {
19182                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19183                            }
19184                    }
19185    
19186                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19187                                    JournalArticle.class.getName(),
19188                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19189    
19190                    Session session = null;
19191    
19192                    try {
19193                            session = openSession();
19194    
19195                            SQLQuery q = session.createSQLQuery(sql);
19196    
19197                            if (getDB().isSupportsInlineDistinct()) {
19198                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19199                            }
19200                            else {
19201                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19202                            }
19203    
19204                            QueryPos qPos = QueryPos.getInstance(q);
19205    
19206                            qPos.add(groupId);
19207    
19208                            qPos.add(classNameId);
19209    
19210                            qPos.add(classPK);
19211    
19212                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19213                                    end);
19214                    }
19215                    catch (Exception e) {
19216                            throw processException(e);
19217                    }
19218                    finally {
19219                            closeSession(session);
19220                    }
19221            }
19222    
19223            /**
19224             * 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;.
19225             *
19226             * @param id the primary key of the current journal article
19227             * @param groupId the group ID
19228             * @param classNameId the class name ID
19229             * @param classPK the class p k
19230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19231             * @return the previous, current, and next journal article
19232             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19233             * @throws SystemException if a system exception occurred
19234             */
19235            @Override
19236            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
19237                    long groupId, long classNameId, long classPK,
19238                    OrderByComparator orderByComparator)
19239                    throws NoSuchArticleException, SystemException {
19240                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19241                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
19242                                    orderByComparator);
19243                    }
19244    
19245                    JournalArticle journalArticle = findByPrimaryKey(id);
19246    
19247                    Session session = null;
19248    
19249                    try {
19250                            session = openSession();
19251    
19252                            JournalArticle[] array = new JournalArticleImpl[3];
19253    
19254                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
19255                                            groupId, classNameId, classPK, orderByComparator, true);
19256    
19257                            array[1] = journalArticle;
19258    
19259                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
19260                                            groupId, classNameId, classPK, orderByComparator, false);
19261    
19262                            return array;
19263                    }
19264                    catch (Exception e) {
19265                            throw processException(e);
19266                    }
19267                    finally {
19268                            closeSession(session);
19269                    }
19270            }
19271    
19272            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
19273                    JournalArticle journalArticle, long groupId, long classNameId,
19274                    long classPK, OrderByComparator orderByComparator, boolean previous) {
19275                    StringBundler query = null;
19276    
19277                    if (orderByComparator != null) {
19278                            query = new StringBundler(6 +
19279                                            (orderByComparator.getOrderByFields().length * 6));
19280                    }
19281                    else {
19282                            query = new StringBundler(3);
19283                    }
19284    
19285                    if (getDB().isSupportsInlineDistinct()) {
19286                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19287                    }
19288                    else {
19289                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19290                    }
19291    
19292                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19293    
19294                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19295    
19296                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19297    
19298                    if (!getDB().isSupportsInlineDistinct()) {
19299                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19300                    }
19301    
19302                    if (orderByComparator != null) {
19303                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19304    
19305                            if (orderByConditionFields.length > 0) {
19306                                    query.append(WHERE_AND);
19307                            }
19308    
19309                            for (int i = 0; i < orderByConditionFields.length; i++) {
19310                                    if (getDB().isSupportsInlineDistinct()) {
19311                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19312                                    }
19313                                    else {
19314                                            query.append(_ORDER_BY_ENTITY_TABLE);
19315                                    }
19316    
19317                                    query.append(orderByConditionFields[i]);
19318    
19319                                    if ((i + 1) < orderByConditionFields.length) {
19320                                            if (orderByComparator.isAscending() ^ previous) {
19321                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19322                                            }
19323                                            else {
19324                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19325                                            }
19326                                    }
19327                                    else {
19328                                            if (orderByComparator.isAscending() ^ previous) {
19329                                                    query.append(WHERE_GREATER_THAN);
19330                                            }
19331                                            else {
19332                                                    query.append(WHERE_LESSER_THAN);
19333                                            }
19334                                    }
19335                            }
19336    
19337                            query.append(ORDER_BY_CLAUSE);
19338    
19339                            String[] orderByFields = orderByComparator.getOrderByFields();
19340    
19341                            for (int i = 0; i < orderByFields.length; i++) {
19342                                    if (getDB().isSupportsInlineDistinct()) {
19343                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19344                                    }
19345                                    else {
19346                                            query.append(_ORDER_BY_ENTITY_TABLE);
19347                                    }
19348    
19349                                    query.append(orderByFields[i]);
19350    
19351                                    if ((i + 1) < orderByFields.length) {
19352                                            if (orderByComparator.isAscending() ^ previous) {
19353                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19354                                            }
19355                                            else {
19356                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19357                                            }
19358                                    }
19359                                    else {
19360                                            if (orderByComparator.isAscending() ^ previous) {
19361                                                    query.append(ORDER_BY_ASC);
19362                                            }
19363                                            else {
19364                                                    query.append(ORDER_BY_DESC);
19365                                            }
19366                                    }
19367                            }
19368                    }
19369                    else {
19370                            if (getDB().isSupportsInlineDistinct()) {
19371                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19372                            }
19373                            else {
19374                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19375                            }
19376                    }
19377    
19378                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19379                                    JournalArticle.class.getName(),
19380                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19381    
19382                    SQLQuery q = session.createSQLQuery(sql);
19383    
19384                    q.setFirstResult(0);
19385                    q.setMaxResults(2);
19386    
19387                    if (getDB().isSupportsInlineDistinct()) {
19388                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19389                    }
19390                    else {
19391                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19392                    }
19393    
19394                    QueryPos qPos = QueryPos.getInstance(q);
19395    
19396                    qPos.add(groupId);
19397    
19398                    qPos.add(classNameId);
19399    
19400                    qPos.add(classPK);
19401    
19402                    if (orderByComparator != null) {
19403                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19404    
19405                            for (Object value : values) {
19406                                    qPos.add(value);
19407                            }
19408                    }
19409    
19410                    List<JournalArticle> list = q.list();
19411    
19412                    if (list.size() == 2) {
19413                            return list.get(1);
19414                    }
19415                    else {
19416                            return null;
19417                    }
19418            }
19419    
19420            /**
19421             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
19422             *
19423             * @param groupId the group ID
19424             * @param classNameId the class name ID
19425             * @param classPK the class p k
19426             * @throws SystemException if a system exception occurred
19427             */
19428            @Override
19429            public void removeByG_C_C(long groupId, long classNameId, long classPK)
19430                    throws SystemException {
19431                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
19432                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19433                            remove(journalArticle);
19434                    }
19435            }
19436    
19437            /**
19438             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19439             *
19440             * @param groupId the group ID
19441             * @param classNameId the class name ID
19442             * @param classPK the class p k
19443             * @return the number of matching journal articles
19444             * @throws SystemException if a system exception occurred
19445             */
19446            @Override
19447            public int countByG_C_C(long groupId, long classNameId, long classPK)
19448                    throws SystemException {
19449                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
19450    
19451                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
19452    
19453                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19454                                    this);
19455    
19456                    if (count == null) {
19457                            StringBundler query = new StringBundler(4);
19458    
19459                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19460    
19461                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19462    
19463                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19464    
19465                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19466    
19467                            String sql = query.toString();
19468    
19469                            Session session = null;
19470    
19471                            try {
19472                                    session = openSession();
19473    
19474                                    Query q = session.createQuery(sql);
19475    
19476                                    QueryPos qPos = QueryPos.getInstance(q);
19477    
19478                                    qPos.add(groupId);
19479    
19480                                    qPos.add(classNameId);
19481    
19482                                    qPos.add(classPK);
19483    
19484                                    count = (Long)q.uniqueResult();
19485    
19486                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19487                            }
19488                            catch (Exception e) {
19489                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19490    
19491                                    throw processException(e);
19492                            }
19493                            finally {
19494                                    closeSession(session);
19495                            }
19496                    }
19497    
19498                    return count.intValue();
19499            }
19500    
19501            /**
19502             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
19503             *
19504             * @param groupId the group ID
19505             * @param classNameId the class name ID
19506             * @param classPK the class p k
19507             * @return the number of matching journal articles that the user has permission to view
19508             * @throws SystemException if a system exception occurred
19509             */
19510            @Override
19511            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
19512                    throws SystemException {
19513                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19514                            return countByG_C_C(groupId, classNameId, classPK);
19515                    }
19516    
19517                    StringBundler query = new StringBundler(4);
19518    
19519                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19520    
19521                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
19522    
19523                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
19524    
19525                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
19526    
19527                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19528                                    JournalArticle.class.getName(),
19529                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19530    
19531                    Session session = null;
19532    
19533                    try {
19534                            session = openSession();
19535    
19536                            SQLQuery q = session.createSQLQuery(sql);
19537    
19538                            q.addScalar(COUNT_COLUMN_NAME,
19539                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19540    
19541                            QueryPos qPos = QueryPos.getInstance(q);
19542    
19543                            qPos.add(groupId);
19544    
19545                            qPos.add(classNameId);
19546    
19547                            qPos.add(classPK);
19548    
19549                            Long count = (Long)q.uniqueResult();
19550    
19551                            return count.intValue();
19552                    }
19553                    catch (Exception e) {
19554                            throw processException(e);
19555                    }
19556                    finally {
19557                            closeSession(session);
19558                    }
19559            }
19560    
19561            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
19562            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19563            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
19564            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19565                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19566                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
19567                            new String[] {
19568                                    Long.class.getName(), Long.class.getName(),
19569                                    String.class.getName()
19570                            },
19571                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19572                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
19573                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
19574            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19575                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19576                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
19577                            new String[] {
19578                                    Long.class.getName(), Long.class.getName(),
19579                                    String.class.getName()
19580                            });
19581    
19582            /**
19583             * 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.
19584             *
19585             * @param groupId the group ID
19586             * @param classNameId the class name ID
19587             * @param structureId the structure ID
19588             * @return the matching journal article
19589             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19590             * @throws SystemException if a system exception occurred
19591             */
19592            @Override
19593            public JournalArticle findByG_C_S(long groupId, long classNameId,
19594                    String structureId) throws NoSuchArticleException, SystemException {
19595                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
19596                                    structureId);
19597    
19598                    if (journalArticle == null) {
19599                            StringBundler msg = new StringBundler(8);
19600    
19601                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19602    
19603                            msg.append("groupId=");
19604                            msg.append(groupId);
19605    
19606                            msg.append(", classNameId=");
19607                            msg.append(classNameId);
19608    
19609                            msg.append(", structureId=");
19610                            msg.append(structureId);
19611    
19612                            msg.append(StringPool.CLOSE_CURLY_BRACE);
19613    
19614                            if (_log.isWarnEnabled()) {
19615                                    _log.warn(msg.toString());
19616                            }
19617    
19618                            throw new NoSuchArticleException(msg.toString());
19619                    }
19620    
19621                    return journalArticle;
19622            }
19623    
19624            /**
19625             * 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.
19626             *
19627             * @param groupId the group ID
19628             * @param classNameId the class name ID
19629             * @param structureId the structure ID
19630             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
19631             * @throws SystemException if a system exception occurred
19632             */
19633            @Override
19634            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
19635                    String structureId) throws SystemException {
19636                    return fetchByG_C_S(groupId, classNameId, structureId, true);
19637            }
19638    
19639            /**
19640             * 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.
19641             *
19642             * @param groupId the group ID
19643             * @param classNameId the class name ID
19644             * @param structureId the structure ID
19645             * @param retrieveFromCache whether to use the finder cache
19646             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
19647             * @throws SystemException if a system exception occurred
19648             */
19649            @Override
19650            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
19651                    String structureId, boolean retrieveFromCache)
19652                    throws SystemException {
19653                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
19654    
19655                    Object result = null;
19656    
19657                    if (retrieveFromCache) {
19658                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
19659                                            finderArgs, this);
19660                    }
19661    
19662                    if (result instanceof JournalArticle) {
19663                            JournalArticle journalArticle = (JournalArticle)result;
19664    
19665                            if ((groupId != journalArticle.getGroupId()) ||
19666                                            (classNameId != journalArticle.getClassNameId()) ||
19667                                            !Validator.equals(structureId,
19668                                                    journalArticle.getStructureId())) {
19669                                    result = null;
19670                            }
19671                    }
19672    
19673                    if (result == null) {
19674                            StringBundler query = new StringBundler(5);
19675    
19676                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19677    
19678                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
19679    
19680                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
19681    
19682                            boolean bindStructureId = false;
19683    
19684                            if (structureId == null) {
19685                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
19686                            }
19687                            else if (structureId.equals(StringPool.BLANK)) {
19688                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
19689                            }
19690                            else {
19691                                    bindStructureId = true;
19692    
19693                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
19694                            }
19695    
19696                            String sql = query.toString();
19697    
19698                            Session session = null;
19699    
19700                            try {
19701                                    session = openSession();
19702    
19703                                    Query q = session.createQuery(sql);
19704    
19705                                    QueryPos qPos = QueryPos.getInstance(q);
19706    
19707                                    qPos.add(groupId);
19708    
19709                                    qPos.add(classNameId);
19710    
19711                                    if (bindStructureId) {
19712                                            qPos.add(structureId);
19713                                    }
19714    
19715                                    List<JournalArticle> list = q.list();
19716    
19717                                    if (list.isEmpty()) {
19718                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
19719                                                    finderArgs, list);
19720                                    }
19721                                    else {
19722                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
19723                                                    _log.warn(
19724                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
19725                                                            StringUtil.merge(finderArgs) +
19726                                                            ") 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.");
19727                                            }
19728    
19729                                            JournalArticle journalArticle = list.get(0);
19730    
19731                                            result = journalArticle;
19732    
19733                                            cacheResult(journalArticle);
19734    
19735                                            if ((journalArticle.getGroupId() != groupId) ||
19736                                                            (journalArticle.getClassNameId() != classNameId) ||
19737                                                            (journalArticle.getStructureId() == null) ||
19738                                                            !journalArticle.getStructureId().equals(structureId)) {
19739                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
19740                                                            finderArgs, journalArticle);
19741                                            }
19742                                    }
19743                            }
19744                            catch (Exception e) {
19745                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
19746                                            finderArgs);
19747    
19748                                    throw processException(e);
19749                            }
19750                            finally {
19751                                    closeSession(session);
19752                            }
19753                    }
19754    
19755                    if (result instanceof List<?>) {
19756                            return null;
19757                    }
19758                    else {
19759                            return (JournalArticle)result;
19760                    }
19761            }
19762    
19763            /**
19764             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
19765             *
19766             * @param groupId the group ID
19767             * @param classNameId the class name ID
19768             * @param structureId the structure ID
19769             * @return the journal article that was removed
19770             * @throws SystemException if a system exception occurred
19771             */
19772            @Override
19773            public JournalArticle removeByG_C_S(long groupId, long classNameId,
19774                    String structureId) throws NoSuchArticleException, SystemException {
19775                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
19776                                    structureId);
19777    
19778                    return remove(journalArticle);
19779            }
19780    
19781            /**
19782             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
19783             *
19784             * @param groupId the group ID
19785             * @param classNameId the class name ID
19786             * @param structureId the structure ID
19787             * @return the number of matching journal articles
19788             * @throws SystemException if a system exception occurred
19789             */
19790            @Override
19791            public int countByG_C_S(long groupId, long classNameId, String structureId)
19792                    throws SystemException {
19793                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
19794    
19795                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
19796    
19797                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19798                                    this);
19799    
19800                    if (count == null) {
19801                            StringBundler query = new StringBundler(4);
19802    
19803                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19804    
19805                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
19806    
19807                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
19808    
19809                            boolean bindStructureId = false;
19810    
19811                            if (structureId == null) {
19812                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
19813                            }
19814                            else if (structureId.equals(StringPool.BLANK)) {
19815                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
19816                            }
19817                            else {
19818                                    bindStructureId = true;
19819    
19820                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
19821                            }
19822    
19823                            String sql = query.toString();
19824    
19825                            Session session = null;
19826    
19827                            try {
19828                                    session = openSession();
19829    
19830                                    Query q = session.createQuery(sql);
19831    
19832                                    QueryPos qPos = QueryPos.getInstance(q);
19833    
19834                                    qPos.add(groupId);
19835    
19836                                    qPos.add(classNameId);
19837    
19838                                    if (bindStructureId) {
19839                                            qPos.add(structureId);
19840                                    }
19841    
19842                                    count = (Long)q.uniqueResult();
19843    
19844                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19845                            }
19846                            catch (Exception e) {
19847                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19848    
19849                                    throw processException(e);
19850                            }
19851                            finally {
19852                                    closeSession(session);
19853                            }
19854                    }
19855    
19856                    return count.intValue();
19857            }
19858    
19859            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
19860            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19861            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
19862            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
19863            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
19864            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19865                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19866                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19867                            "findByG_C_T",
19868                            new String[] {
19869                                    Long.class.getName(), Long.class.getName(),
19870                                    String.class.getName(),
19871                                    
19872                            Integer.class.getName(), Integer.class.getName(),
19873                                    OrderByComparator.class.getName()
19874                            });
19875            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19876                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19877                            JournalArticleImpl.class,
19878                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
19879                            new String[] {
19880                                    Long.class.getName(), Long.class.getName(),
19881                                    String.class.getName()
19882                            },
19883                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19884                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
19885                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
19886                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19887                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19888            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19889                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19890                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
19891                            new String[] {
19892                                    Long.class.getName(), Long.class.getName(),
19893                                    String.class.getName()
19894                            });
19895    
19896            /**
19897             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19898             *
19899             * @param groupId the group ID
19900             * @param classNameId the class name ID
19901             * @param templateId the template ID
19902             * @return the matching journal articles
19903             * @throws SystemException if a system exception occurred
19904             */
19905            @Override
19906            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
19907                    String templateId) throws SystemException {
19908                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
19909                            QueryUtil.ALL_POS, null);
19910            }
19911    
19912            /**
19913             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19914             *
19915             * <p>
19916             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19917             * </p>
19918             *
19919             * @param groupId the group ID
19920             * @param classNameId the class name ID
19921             * @param templateId the template ID
19922             * @param start the lower bound of the range of journal articles
19923             * @param end the upper bound of the range of journal articles (not inclusive)
19924             * @return the range of matching journal articles
19925             * @throws SystemException if a system exception occurred
19926             */
19927            @Override
19928            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
19929                    String templateId, int start, int end) throws SystemException {
19930                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
19931            }
19932    
19933            /**
19934             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19935             *
19936             * <p>
19937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19938             * </p>
19939             *
19940             * @param groupId the group ID
19941             * @param classNameId the class name ID
19942             * @param templateId the template ID
19943             * @param start the lower bound of the range of journal articles
19944             * @param end the upper bound of the range of journal articles (not inclusive)
19945             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19946             * @return the ordered range of matching journal articles
19947             * @throws SystemException if a system exception occurred
19948             */
19949            @Override
19950            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
19951                    String templateId, int start, int end,
19952                    OrderByComparator orderByComparator) throws SystemException {
19953                    boolean pagination = true;
19954                    FinderPath finderPath = null;
19955                    Object[] finderArgs = null;
19956    
19957                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19958                                    (orderByComparator == null)) {
19959                            pagination = false;
19960                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
19961                            finderArgs = new Object[] { groupId, classNameId, templateId };
19962                    }
19963                    else {
19964                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
19965                            finderArgs = new Object[] {
19966                                            groupId, classNameId, templateId,
19967                                            
19968                                            start, end, orderByComparator
19969                                    };
19970                    }
19971    
19972                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19973                                    finderArgs, this);
19974    
19975                    if ((list != null) && !list.isEmpty()) {
19976                            for (JournalArticle journalArticle : list) {
19977                                    if ((groupId != journalArticle.getGroupId()) ||
19978                                                    (classNameId != journalArticle.getClassNameId()) ||
19979                                                    !Validator.equals(templateId,
19980                                                            journalArticle.getTemplateId())) {
19981                                            list = null;
19982    
19983                                            break;
19984                                    }
19985                            }
19986                    }
19987    
19988                    if (list == null) {
19989                            StringBundler query = null;
19990    
19991                            if (orderByComparator != null) {
19992                                    query = new StringBundler(5 +
19993                                                    (orderByComparator.getOrderByFields().length * 3));
19994                            }
19995                            else {
19996                                    query = new StringBundler(5);
19997                            }
19998    
19999                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20000    
20001                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20002    
20003                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20004    
20005                            boolean bindTemplateId = false;
20006    
20007                            if (templateId == null) {
20008                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20009                            }
20010                            else if (templateId.equals(StringPool.BLANK)) {
20011                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20012                            }
20013                            else {
20014                                    bindTemplateId = true;
20015    
20016                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20017                            }
20018    
20019                            if (orderByComparator != null) {
20020                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20021                                            orderByComparator);
20022                            }
20023                            else
20024                             if (pagination) {
20025                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20026                            }
20027    
20028                            String sql = query.toString();
20029    
20030                            Session session = null;
20031    
20032                            try {
20033                                    session = openSession();
20034    
20035                                    Query q = session.createQuery(sql);
20036    
20037                                    QueryPos qPos = QueryPos.getInstance(q);
20038    
20039                                    qPos.add(groupId);
20040    
20041                                    qPos.add(classNameId);
20042    
20043                                    if (bindTemplateId) {
20044                                            qPos.add(templateId);
20045                                    }
20046    
20047                                    if (!pagination) {
20048                                            list = (List<JournalArticle>)QueryUtil.list(q,
20049                                                            getDialect(), start, end, false);
20050    
20051                                            Collections.sort(list);
20052    
20053                                            list = new UnmodifiableList<JournalArticle>(list);
20054                                    }
20055                                    else {
20056                                            list = (List<JournalArticle>)QueryUtil.list(q,
20057                                                            getDialect(), start, end);
20058                                    }
20059    
20060                                    cacheResult(list);
20061    
20062                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20063                            }
20064                            catch (Exception e) {
20065                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20066    
20067                                    throw processException(e);
20068                            }
20069                            finally {
20070                                    closeSession(session);
20071                            }
20072                    }
20073    
20074                    return list;
20075            }
20076    
20077            /**
20078             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20079             *
20080             * @param groupId the group ID
20081             * @param classNameId the class name ID
20082             * @param templateId the template ID
20083             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20084             * @return the first matching journal article
20085             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20086             * @throws SystemException if a system exception occurred
20087             */
20088            @Override
20089            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
20090                    String templateId, OrderByComparator orderByComparator)
20091                    throws NoSuchArticleException, SystemException {
20092                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
20093                                    classNameId, templateId, orderByComparator);
20094    
20095                    if (journalArticle != null) {
20096                            return journalArticle;
20097                    }
20098    
20099                    StringBundler msg = new StringBundler(8);
20100    
20101                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20102    
20103                    msg.append("groupId=");
20104                    msg.append(groupId);
20105    
20106                    msg.append(", classNameId=");
20107                    msg.append(classNameId);
20108    
20109                    msg.append(", templateId=");
20110                    msg.append(templateId);
20111    
20112                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20113    
20114                    throw new NoSuchArticleException(msg.toString());
20115            }
20116    
20117            /**
20118             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20119             *
20120             * @param groupId the group ID
20121             * @param classNameId the class name ID
20122             * @param templateId the template ID
20123             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20124             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
20125             * @throws SystemException if a system exception occurred
20126             */
20127            @Override
20128            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
20129                    String templateId, OrderByComparator orderByComparator)
20130                    throws SystemException {
20131                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
20132                                    templateId, 0, 1, orderByComparator);
20133    
20134                    if (!list.isEmpty()) {
20135                            return list.get(0);
20136                    }
20137    
20138                    return null;
20139            }
20140    
20141            /**
20142             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20143             *
20144             * @param groupId the group ID
20145             * @param classNameId the class name ID
20146             * @param templateId the template ID
20147             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20148             * @return the last matching journal article
20149             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20150             * @throws SystemException if a system exception occurred
20151             */
20152            @Override
20153            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
20154                    String templateId, OrderByComparator orderByComparator)
20155                    throws NoSuchArticleException, SystemException {
20156                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
20157                                    templateId, orderByComparator);
20158    
20159                    if (journalArticle != null) {
20160                            return journalArticle;
20161                    }
20162    
20163                    StringBundler msg = new StringBundler(8);
20164    
20165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20166    
20167                    msg.append("groupId=");
20168                    msg.append(groupId);
20169    
20170                    msg.append(", classNameId=");
20171                    msg.append(classNameId);
20172    
20173                    msg.append(", templateId=");
20174                    msg.append(templateId);
20175    
20176                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20177    
20178                    throw new NoSuchArticleException(msg.toString());
20179            }
20180    
20181            /**
20182             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20183             *
20184             * @param groupId the group ID
20185             * @param classNameId the class name ID
20186             * @param templateId the template ID
20187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20188             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20189             * @throws SystemException if a system exception occurred
20190             */
20191            @Override
20192            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
20193                    String templateId, OrderByComparator orderByComparator)
20194                    throws SystemException {
20195                    int count = countByG_C_T(groupId, classNameId, templateId);
20196    
20197                    if (count == 0) {
20198                            return null;
20199                    }
20200    
20201                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
20202                                    templateId, count - 1, count, orderByComparator);
20203    
20204                    if (!list.isEmpty()) {
20205                            return list.get(0);
20206                    }
20207    
20208                    return null;
20209            }
20210    
20211            /**
20212             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20213             *
20214             * @param id the primary key of the current journal article
20215             * @param groupId the group ID
20216             * @param classNameId the class name ID
20217             * @param templateId the template ID
20218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20219             * @return the previous, current, and next journal article
20220             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20221             * @throws SystemException if a system exception occurred
20222             */
20223            @Override
20224            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
20225                    long classNameId, String templateId, OrderByComparator orderByComparator)
20226                    throws NoSuchArticleException, SystemException {
20227                    JournalArticle journalArticle = findByPrimaryKey(id);
20228    
20229                    Session session = null;
20230    
20231                    try {
20232                            session = openSession();
20233    
20234                            JournalArticle[] array = new JournalArticleImpl[3];
20235    
20236                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
20237                                            classNameId, templateId, orderByComparator, true);
20238    
20239                            array[1] = journalArticle;
20240    
20241                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
20242                                            classNameId, templateId, orderByComparator, false);
20243    
20244                            return array;
20245                    }
20246                    catch (Exception e) {
20247                            throw processException(e);
20248                    }
20249                    finally {
20250                            closeSession(session);
20251                    }
20252            }
20253    
20254            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
20255                    JournalArticle journalArticle, long groupId, long classNameId,
20256                    String templateId, OrderByComparator orderByComparator, boolean previous) {
20257                    StringBundler query = null;
20258    
20259                    if (orderByComparator != null) {
20260                            query = new StringBundler(6 +
20261                                            (orderByComparator.getOrderByFields().length * 6));
20262                    }
20263                    else {
20264                            query = new StringBundler(3);
20265                    }
20266    
20267                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20268    
20269                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20270    
20271                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20272    
20273                    boolean bindTemplateId = false;
20274    
20275                    if (templateId == null) {
20276                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20277                    }
20278                    else if (templateId.equals(StringPool.BLANK)) {
20279                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20280                    }
20281                    else {
20282                            bindTemplateId = true;
20283    
20284                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20285                    }
20286    
20287                    if (orderByComparator != null) {
20288                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20289    
20290                            if (orderByConditionFields.length > 0) {
20291                                    query.append(WHERE_AND);
20292                            }
20293    
20294                            for (int i = 0; i < orderByConditionFields.length; i++) {
20295                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20296                                    query.append(orderByConditionFields[i]);
20297    
20298                                    if ((i + 1) < orderByConditionFields.length) {
20299                                            if (orderByComparator.isAscending() ^ previous) {
20300                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20301                                            }
20302                                            else {
20303                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20304                                            }
20305                                    }
20306                                    else {
20307                                            if (orderByComparator.isAscending() ^ previous) {
20308                                                    query.append(WHERE_GREATER_THAN);
20309                                            }
20310                                            else {
20311                                                    query.append(WHERE_LESSER_THAN);
20312                                            }
20313                                    }
20314                            }
20315    
20316                            query.append(ORDER_BY_CLAUSE);
20317    
20318                            String[] orderByFields = orderByComparator.getOrderByFields();
20319    
20320                            for (int i = 0; i < orderByFields.length; i++) {
20321                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20322                                    query.append(orderByFields[i]);
20323    
20324                                    if ((i + 1) < orderByFields.length) {
20325                                            if (orderByComparator.isAscending() ^ previous) {
20326                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20327                                            }
20328                                            else {
20329                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20330                                            }
20331                                    }
20332                                    else {
20333                                            if (orderByComparator.isAscending() ^ previous) {
20334                                                    query.append(ORDER_BY_ASC);
20335                                            }
20336                                            else {
20337                                                    query.append(ORDER_BY_DESC);
20338                                            }
20339                                    }
20340                            }
20341                    }
20342                    else {
20343                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20344                    }
20345    
20346                    String sql = query.toString();
20347    
20348                    Query q = session.createQuery(sql);
20349    
20350                    q.setFirstResult(0);
20351                    q.setMaxResults(2);
20352    
20353                    QueryPos qPos = QueryPos.getInstance(q);
20354    
20355                    qPos.add(groupId);
20356    
20357                    qPos.add(classNameId);
20358    
20359                    if (bindTemplateId) {
20360                            qPos.add(templateId);
20361                    }
20362    
20363                    if (orderByComparator != null) {
20364                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20365    
20366                            for (Object value : values) {
20367                                    qPos.add(value);
20368                            }
20369                    }
20370    
20371                    List<JournalArticle> list = q.list();
20372    
20373                    if (list.size() == 2) {
20374                            return list.get(1);
20375                    }
20376                    else {
20377                            return null;
20378                    }
20379            }
20380    
20381            /**
20382             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20383             *
20384             * @param groupId the group ID
20385             * @param classNameId the class name ID
20386             * @param templateId the template ID
20387             * @return the matching journal articles that the user has permission to view
20388             * @throws SystemException if a system exception occurred
20389             */
20390            @Override
20391            public List<JournalArticle> filterFindByG_C_T(long groupId,
20392                    long classNameId, String templateId) throws SystemException {
20393                    return filterFindByG_C_T(groupId, classNameId, templateId,
20394                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20395            }
20396    
20397            /**
20398             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20399             *
20400             * <p>
20401             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20402             * </p>
20403             *
20404             * @param groupId the group ID
20405             * @param classNameId the class name ID
20406             * @param templateId the template ID
20407             * @param start the lower bound of the range of journal articles
20408             * @param end the upper bound of the range of journal articles (not inclusive)
20409             * @return the range of matching journal articles that the user has permission to view
20410             * @throws SystemException if a system exception occurred
20411             */
20412            @Override
20413            public List<JournalArticle> filterFindByG_C_T(long groupId,
20414                    long classNameId, String templateId, int start, int end)
20415                    throws SystemException {
20416                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
20417                            null);
20418            }
20419    
20420            /**
20421             * 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;.
20422             *
20423             * <p>
20424             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20425             * </p>
20426             *
20427             * @param groupId the group ID
20428             * @param classNameId the class name ID
20429             * @param templateId the template ID
20430             * @param start the lower bound of the range of journal articles
20431             * @param end the upper bound of the range of journal articles (not inclusive)
20432             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20433             * @return the ordered range of matching journal articles that the user has permission to view
20434             * @throws SystemException if a system exception occurred
20435             */
20436            @Override
20437            public List<JournalArticle> filterFindByG_C_T(long groupId,
20438                    long classNameId, String templateId, int start, int end,
20439                    OrderByComparator orderByComparator) throws SystemException {
20440                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20441                            return findByG_C_T(groupId, classNameId, templateId, start, end,
20442                                    orderByComparator);
20443                    }
20444    
20445                    StringBundler query = null;
20446    
20447                    if (orderByComparator != null) {
20448                            query = new StringBundler(5 +
20449                                            (orderByComparator.getOrderByFields().length * 3));
20450                    }
20451                    else {
20452                            query = new StringBundler(5);
20453                    }
20454    
20455                    if (getDB().isSupportsInlineDistinct()) {
20456                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20457                    }
20458                    else {
20459                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20460                    }
20461    
20462                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20463    
20464                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20465    
20466                    boolean bindTemplateId = false;
20467    
20468                    if (templateId == null) {
20469                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20470                    }
20471                    else if (templateId.equals(StringPool.BLANK)) {
20472                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20473                    }
20474                    else {
20475                            bindTemplateId = true;
20476    
20477                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20478                    }
20479    
20480                    if (!getDB().isSupportsInlineDistinct()) {
20481                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20482                    }
20483    
20484                    if (orderByComparator != null) {
20485                            if (getDB().isSupportsInlineDistinct()) {
20486                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20487                                            orderByComparator, true);
20488                            }
20489                            else {
20490                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20491                                            orderByComparator, true);
20492                            }
20493                    }
20494                    else {
20495                            if (getDB().isSupportsInlineDistinct()) {
20496                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20497                            }
20498                            else {
20499                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20500                            }
20501                    }
20502    
20503                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20504                                    JournalArticle.class.getName(),
20505                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20506    
20507                    Session session = null;
20508    
20509                    try {
20510                            session = openSession();
20511    
20512                            SQLQuery q = session.createSQLQuery(sql);
20513    
20514                            if (getDB().isSupportsInlineDistinct()) {
20515                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20516                            }
20517                            else {
20518                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20519                            }
20520    
20521                            QueryPos qPos = QueryPos.getInstance(q);
20522    
20523                            qPos.add(groupId);
20524    
20525                            qPos.add(classNameId);
20526    
20527                            if (bindTemplateId) {
20528                                    qPos.add(templateId);
20529                            }
20530    
20531                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20532                                    end);
20533                    }
20534                    catch (Exception e) {
20535                            throw processException(e);
20536                    }
20537                    finally {
20538                            closeSession(session);
20539                    }
20540            }
20541    
20542            /**
20543             * 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;.
20544             *
20545             * @param id the primary key of the current journal article
20546             * @param groupId the group ID
20547             * @param classNameId the class name ID
20548             * @param templateId the template ID
20549             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20550             * @return the previous, current, and next journal article
20551             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20552             * @throws SystemException if a system exception occurred
20553             */
20554            @Override
20555            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
20556                    long groupId, long classNameId, String templateId,
20557                    OrderByComparator orderByComparator)
20558                    throws NoSuchArticleException, SystemException {
20559                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20560                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
20561                                    templateId, orderByComparator);
20562                    }
20563    
20564                    JournalArticle journalArticle = findByPrimaryKey(id);
20565    
20566                    Session session = null;
20567    
20568                    try {
20569                            session = openSession();
20570    
20571                            JournalArticle[] array = new JournalArticleImpl[3];
20572    
20573                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
20574                                            groupId, classNameId, templateId, orderByComparator, true);
20575    
20576                            array[1] = journalArticle;
20577    
20578                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
20579                                            groupId, classNameId, templateId, orderByComparator, false);
20580    
20581                            return array;
20582                    }
20583                    catch (Exception e) {
20584                            throw processException(e);
20585                    }
20586                    finally {
20587                            closeSession(session);
20588                    }
20589            }
20590    
20591            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
20592                    JournalArticle journalArticle, long groupId, long classNameId,
20593                    String templateId, OrderByComparator orderByComparator, boolean previous) {
20594                    StringBundler query = null;
20595    
20596                    if (orderByComparator != null) {
20597                            query = new StringBundler(6 +
20598                                            (orderByComparator.getOrderByFields().length * 6));
20599                    }
20600                    else {
20601                            query = new StringBundler(3);
20602                    }
20603    
20604                    if (getDB().isSupportsInlineDistinct()) {
20605                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20606                    }
20607                    else {
20608                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20609                    }
20610    
20611                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20612    
20613                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20614    
20615                    boolean bindTemplateId = false;
20616    
20617                    if (templateId == null) {
20618                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20619                    }
20620                    else if (templateId.equals(StringPool.BLANK)) {
20621                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20622                    }
20623                    else {
20624                            bindTemplateId = true;
20625    
20626                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20627                    }
20628    
20629                    if (!getDB().isSupportsInlineDistinct()) {
20630                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20631                    }
20632    
20633                    if (orderByComparator != null) {
20634                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20635    
20636                            if (orderByConditionFields.length > 0) {
20637                                    query.append(WHERE_AND);
20638                            }
20639    
20640                            for (int i = 0; i < orderByConditionFields.length; i++) {
20641                                    if (getDB().isSupportsInlineDistinct()) {
20642                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20643                                    }
20644                                    else {
20645                                            query.append(_ORDER_BY_ENTITY_TABLE);
20646                                    }
20647    
20648                                    query.append(orderByConditionFields[i]);
20649    
20650                                    if ((i + 1) < orderByConditionFields.length) {
20651                                            if (orderByComparator.isAscending() ^ previous) {
20652                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20653                                            }
20654                                            else {
20655                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20656                                            }
20657                                    }
20658                                    else {
20659                                            if (orderByComparator.isAscending() ^ previous) {
20660                                                    query.append(WHERE_GREATER_THAN);
20661                                            }
20662                                            else {
20663                                                    query.append(WHERE_LESSER_THAN);
20664                                            }
20665                                    }
20666                            }
20667    
20668                            query.append(ORDER_BY_CLAUSE);
20669    
20670                            String[] orderByFields = orderByComparator.getOrderByFields();
20671    
20672                            for (int i = 0; i < orderByFields.length; i++) {
20673                                    if (getDB().isSupportsInlineDistinct()) {
20674                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20675                                    }
20676                                    else {
20677                                            query.append(_ORDER_BY_ENTITY_TABLE);
20678                                    }
20679    
20680                                    query.append(orderByFields[i]);
20681    
20682                                    if ((i + 1) < orderByFields.length) {
20683                                            if (orderByComparator.isAscending() ^ previous) {
20684                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20685                                            }
20686                                            else {
20687                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20688                                            }
20689                                    }
20690                                    else {
20691                                            if (orderByComparator.isAscending() ^ previous) {
20692                                                    query.append(ORDER_BY_ASC);
20693                                            }
20694                                            else {
20695                                                    query.append(ORDER_BY_DESC);
20696                                            }
20697                                    }
20698                            }
20699                    }
20700                    else {
20701                            if (getDB().isSupportsInlineDistinct()) {
20702                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20703                            }
20704                            else {
20705                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20706                            }
20707                    }
20708    
20709                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20710                                    JournalArticle.class.getName(),
20711                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20712    
20713                    SQLQuery q = session.createSQLQuery(sql);
20714    
20715                    q.setFirstResult(0);
20716                    q.setMaxResults(2);
20717    
20718                    if (getDB().isSupportsInlineDistinct()) {
20719                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20720                    }
20721                    else {
20722                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20723                    }
20724    
20725                    QueryPos qPos = QueryPos.getInstance(q);
20726    
20727                    qPos.add(groupId);
20728    
20729                    qPos.add(classNameId);
20730    
20731                    if (bindTemplateId) {
20732                            qPos.add(templateId);
20733                    }
20734    
20735                    if (orderByComparator != null) {
20736                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20737    
20738                            for (Object value : values) {
20739                                    qPos.add(value);
20740                            }
20741                    }
20742    
20743                    List<JournalArticle> list = q.list();
20744    
20745                    if (list.size() == 2) {
20746                            return list.get(1);
20747                    }
20748                    else {
20749                            return null;
20750                    }
20751            }
20752    
20753            /**
20754             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
20755             *
20756             * @param groupId the group ID
20757             * @param classNameId the class name ID
20758             * @param templateId the template ID
20759             * @throws SystemException if a system exception occurred
20760             */
20761            @Override
20762            public void removeByG_C_T(long groupId, long classNameId, String templateId)
20763                    throws SystemException {
20764                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
20765                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20766                            remove(journalArticle);
20767                    }
20768            }
20769    
20770            /**
20771             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20772             *
20773             * @param groupId the group ID
20774             * @param classNameId the class name ID
20775             * @param templateId the template ID
20776             * @return the number of matching journal articles
20777             * @throws SystemException if a system exception occurred
20778             */
20779            @Override
20780            public int countByG_C_T(long groupId, long classNameId, String templateId)
20781                    throws SystemException {
20782                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
20783    
20784                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
20785    
20786                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20787                                    this);
20788    
20789                    if (count == null) {
20790                            StringBundler query = new StringBundler(4);
20791    
20792                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20793    
20794                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20795    
20796                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20797    
20798                            boolean bindTemplateId = false;
20799    
20800                            if (templateId == null) {
20801                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20802                            }
20803                            else if (templateId.equals(StringPool.BLANK)) {
20804                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20805                            }
20806                            else {
20807                                    bindTemplateId = true;
20808    
20809                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20810                            }
20811    
20812                            String sql = query.toString();
20813    
20814                            Session session = null;
20815    
20816                            try {
20817                                    session = openSession();
20818    
20819                                    Query q = session.createQuery(sql);
20820    
20821                                    QueryPos qPos = QueryPos.getInstance(q);
20822    
20823                                    qPos.add(groupId);
20824    
20825                                    qPos.add(classNameId);
20826    
20827                                    if (bindTemplateId) {
20828                                            qPos.add(templateId);
20829                                    }
20830    
20831                                    count = (Long)q.uniqueResult();
20832    
20833                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20834                            }
20835                            catch (Exception e) {
20836                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20837    
20838                                    throw processException(e);
20839                            }
20840                            finally {
20841                                    closeSession(session);
20842                            }
20843                    }
20844    
20845                    return count.intValue();
20846            }
20847    
20848            /**
20849             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
20850             *
20851             * @param groupId the group ID
20852             * @param classNameId the class name ID
20853             * @param templateId the template ID
20854             * @return the number of matching journal articles that the user has permission to view
20855             * @throws SystemException if a system exception occurred
20856             */
20857            @Override
20858            public int filterCountByG_C_T(long groupId, long classNameId,
20859                    String templateId) throws SystemException {
20860                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20861                            return countByG_C_T(groupId, classNameId, templateId);
20862                    }
20863    
20864                    StringBundler query = new StringBundler(4);
20865    
20866                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20867    
20868                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
20869    
20870                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
20871    
20872                    boolean bindTemplateId = false;
20873    
20874                    if (templateId == null) {
20875                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
20876                    }
20877                    else if (templateId.equals(StringPool.BLANK)) {
20878                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
20879                    }
20880                    else {
20881                            bindTemplateId = true;
20882    
20883                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
20884                    }
20885    
20886                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20887                                    JournalArticle.class.getName(),
20888                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20889    
20890                    Session session = null;
20891    
20892                    try {
20893                            session = openSession();
20894    
20895                            SQLQuery q = session.createSQLQuery(sql);
20896    
20897                            q.addScalar(COUNT_COLUMN_NAME,
20898                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20899    
20900                            QueryPos qPos = QueryPos.getInstance(q);
20901    
20902                            qPos.add(groupId);
20903    
20904                            qPos.add(classNameId);
20905    
20906                            if (bindTemplateId) {
20907                                    qPos.add(templateId);
20908                            }
20909    
20910                            Long count = (Long)q.uniqueResult();
20911    
20912                            return count.intValue();
20913                    }
20914                    catch (Exception e) {
20915                            throw processException(e);
20916                    }
20917                    finally {
20918                            closeSession(session);
20919                    }
20920            }
20921    
20922            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
20923            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
20924            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
20925            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
20926            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
20927            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20928                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20929                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20930                            "findByG_C_L",
20931                            new String[] {
20932                                    Long.class.getName(), Long.class.getName(),
20933                                    String.class.getName(),
20934                                    
20935                            Integer.class.getName(), Integer.class.getName(),
20936                                    OrderByComparator.class.getName()
20937                            });
20938            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20939                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20940                            JournalArticleImpl.class,
20941                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
20942                            new String[] {
20943                                    Long.class.getName(), Long.class.getName(),
20944                                    String.class.getName()
20945                            },
20946                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20947                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20948                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
20949                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20950                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20951            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20952                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20953                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
20954                            new String[] {
20955                                    Long.class.getName(), Long.class.getName(),
20956                                    String.class.getName()
20957                            });
20958    
20959            /**
20960             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20961             *
20962             * @param groupId the group ID
20963             * @param classNameId the class name ID
20964             * @param layoutUuid the layout uuid
20965             * @return the matching journal articles
20966             * @throws SystemException if a system exception occurred
20967             */
20968            @Override
20969            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
20970                    String layoutUuid) throws SystemException {
20971                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
20972                            QueryUtil.ALL_POS, null);
20973            }
20974    
20975            /**
20976             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20977             *
20978             * <p>
20979             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20980             * </p>
20981             *
20982             * @param groupId the group ID
20983             * @param classNameId the class name ID
20984             * @param layoutUuid the layout uuid
20985             * @param start the lower bound of the range of journal articles
20986             * @param end the upper bound of the range of journal articles (not inclusive)
20987             * @return the range of matching journal articles
20988             * @throws SystemException if a system exception occurred
20989             */
20990            @Override
20991            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
20992                    String layoutUuid, int start, int end) throws SystemException {
20993                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
20994            }
20995    
20996            /**
20997             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20998             *
20999             * <p>
21000             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21001             * </p>
21002             *
21003             * @param groupId the group ID
21004             * @param classNameId the class name ID
21005             * @param layoutUuid the layout uuid
21006             * @param start the lower bound of the range of journal articles
21007             * @param end the upper bound of the range of journal articles (not inclusive)
21008             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21009             * @return the ordered range of matching journal articles
21010             * @throws SystemException if a system exception occurred
21011             */
21012            @Override
21013            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
21014                    String layoutUuid, int start, int end,
21015                    OrderByComparator orderByComparator) throws SystemException {
21016                    boolean pagination = true;
21017                    FinderPath finderPath = null;
21018                    Object[] finderArgs = null;
21019    
21020                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21021                                    (orderByComparator == null)) {
21022                            pagination = false;
21023                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
21024                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
21025                    }
21026                    else {
21027                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
21028                            finderArgs = new Object[] {
21029                                            groupId, classNameId, layoutUuid,
21030                                            
21031                                            start, end, orderByComparator
21032                                    };
21033                    }
21034    
21035                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21036                                    finderArgs, this);
21037    
21038                    if ((list != null) && !list.isEmpty()) {
21039                            for (JournalArticle journalArticle : list) {
21040                                    if ((groupId != journalArticle.getGroupId()) ||
21041                                                    (classNameId != journalArticle.getClassNameId()) ||
21042                                                    !Validator.equals(layoutUuid,
21043                                                            journalArticle.getLayoutUuid())) {
21044                                            list = null;
21045    
21046                                            break;
21047                                    }
21048                            }
21049                    }
21050    
21051                    if (list == null) {
21052                            StringBundler query = null;
21053    
21054                            if (orderByComparator != null) {
21055                                    query = new StringBundler(5 +
21056                                                    (orderByComparator.getOrderByFields().length * 3));
21057                            }
21058                            else {
21059                                    query = new StringBundler(5);
21060                            }
21061    
21062                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21063    
21064                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21065    
21066                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21067    
21068                            boolean bindLayoutUuid = false;
21069    
21070                            if (layoutUuid == null) {
21071                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21072                            }
21073                            else if (layoutUuid.equals(StringPool.BLANK)) {
21074                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21075                            }
21076                            else {
21077                                    bindLayoutUuid = true;
21078    
21079                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21080                            }
21081    
21082                            if (orderByComparator != null) {
21083                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21084                                            orderByComparator);
21085                            }
21086                            else
21087                             if (pagination) {
21088                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21089                            }
21090    
21091                            String sql = query.toString();
21092    
21093                            Session session = null;
21094    
21095                            try {
21096                                    session = openSession();
21097    
21098                                    Query q = session.createQuery(sql);
21099    
21100                                    QueryPos qPos = QueryPos.getInstance(q);
21101    
21102                                    qPos.add(groupId);
21103    
21104                                    qPos.add(classNameId);
21105    
21106                                    if (bindLayoutUuid) {
21107                                            qPos.add(layoutUuid);
21108                                    }
21109    
21110                                    if (!pagination) {
21111                                            list = (List<JournalArticle>)QueryUtil.list(q,
21112                                                            getDialect(), start, end, false);
21113    
21114                                            Collections.sort(list);
21115    
21116                                            list = new UnmodifiableList<JournalArticle>(list);
21117                                    }
21118                                    else {
21119                                            list = (List<JournalArticle>)QueryUtil.list(q,
21120                                                            getDialect(), start, end);
21121                                    }
21122    
21123                                    cacheResult(list);
21124    
21125                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21126                            }
21127                            catch (Exception e) {
21128                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21129    
21130                                    throw processException(e);
21131                            }
21132                            finally {
21133                                    closeSession(session);
21134                            }
21135                    }
21136    
21137                    return list;
21138            }
21139    
21140            /**
21141             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21142             *
21143             * @param groupId the group ID
21144             * @param classNameId the class name ID
21145             * @param layoutUuid the layout uuid
21146             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21147             * @return the first matching journal article
21148             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21149             * @throws SystemException if a system exception occurred
21150             */
21151            @Override
21152            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
21153                    String layoutUuid, OrderByComparator orderByComparator)
21154                    throws NoSuchArticleException, SystemException {
21155                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
21156                                    classNameId, layoutUuid, orderByComparator);
21157    
21158                    if (journalArticle != null) {
21159                            return journalArticle;
21160                    }
21161    
21162                    StringBundler msg = new StringBundler(8);
21163    
21164                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21165    
21166                    msg.append("groupId=");
21167                    msg.append(groupId);
21168    
21169                    msg.append(", classNameId=");
21170                    msg.append(classNameId);
21171    
21172                    msg.append(", layoutUuid=");
21173                    msg.append(layoutUuid);
21174    
21175                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21176    
21177                    throw new NoSuchArticleException(msg.toString());
21178            }
21179    
21180            /**
21181             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21182             *
21183             * @param groupId the group ID
21184             * @param classNameId the class name ID
21185             * @param layoutUuid the layout uuid
21186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21187             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21188             * @throws SystemException if a system exception occurred
21189             */
21190            @Override
21191            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
21192                    String layoutUuid, OrderByComparator orderByComparator)
21193                    throws SystemException {
21194                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
21195                                    layoutUuid, 0, 1, orderByComparator);
21196    
21197                    if (!list.isEmpty()) {
21198                            return list.get(0);
21199                    }
21200    
21201                    return null;
21202            }
21203    
21204            /**
21205             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21206             *
21207             * @param groupId the group ID
21208             * @param classNameId the class name ID
21209             * @param layoutUuid the layout uuid
21210             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21211             * @return the last matching journal article
21212             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21213             * @throws SystemException if a system exception occurred
21214             */
21215            @Override
21216            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
21217                    String layoutUuid, OrderByComparator orderByComparator)
21218                    throws NoSuchArticleException, SystemException {
21219                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
21220                                    layoutUuid, orderByComparator);
21221    
21222                    if (journalArticle != null) {
21223                            return journalArticle;
21224                    }
21225    
21226                    StringBundler msg = new StringBundler(8);
21227    
21228                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21229    
21230                    msg.append("groupId=");
21231                    msg.append(groupId);
21232    
21233                    msg.append(", classNameId=");
21234                    msg.append(classNameId);
21235    
21236                    msg.append(", layoutUuid=");
21237                    msg.append(layoutUuid);
21238    
21239                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21240    
21241                    throw new NoSuchArticleException(msg.toString());
21242            }
21243    
21244            /**
21245             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21246             *
21247             * @param groupId the group ID
21248             * @param classNameId the class name ID
21249             * @param layoutUuid the layout uuid
21250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21251             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21252             * @throws SystemException if a system exception occurred
21253             */
21254            @Override
21255            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
21256                    String layoutUuid, OrderByComparator orderByComparator)
21257                    throws SystemException {
21258                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
21259    
21260                    if (count == 0) {
21261                            return null;
21262                    }
21263    
21264                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
21265                                    layoutUuid, count - 1, count, orderByComparator);
21266    
21267                    if (!list.isEmpty()) {
21268                            return list.get(0);
21269                    }
21270    
21271                    return null;
21272            }
21273    
21274            /**
21275             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21276             *
21277             * @param id the primary key of the current journal article
21278             * @param groupId the group ID
21279             * @param classNameId the class name ID
21280             * @param layoutUuid the layout uuid
21281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21282             * @return the previous, current, and next journal article
21283             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21284             * @throws SystemException if a system exception occurred
21285             */
21286            @Override
21287            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
21288                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
21289                    throws NoSuchArticleException, SystemException {
21290                    JournalArticle journalArticle = findByPrimaryKey(id);
21291    
21292                    Session session = null;
21293    
21294                    try {
21295                            session = openSession();
21296    
21297                            JournalArticle[] array = new JournalArticleImpl[3];
21298    
21299                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
21300                                            classNameId, layoutUuid, orderByComparator, true);
21301    
21302                            array[1] = journalArticle;
21303    
21304                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
21305                                            classNameId, layoutUuid, orderByComparator, false);
21306    
21307                            return array;
21308                    }
21309                    catch (Exception e) {
21310                            throw processException(e);
21311                    }
21312                    finally {
21313                            closeSession(session);
21314                    }
21315            }
21316    
21317            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
21318                    JournalArticle journalArticle, long groupId, long classNameId,
21319                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
21320                    StringBundler query = null;
21321    
21322                    if (orderByComparator != null) {
21323                            query = new StringBundler(6 +
21324                                            (orderByComparator.getOrderByFields().length * 6));
21325                    }
21326                    else {
21327                            query = new StringBundler(3);
21328                    }
21329    
21330                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21331    
21332                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21333    
21334                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21335    
21336                    boolean bindLayoutUuid = false;
21337    
21338                    if (layoutUuid == null) {
21339                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21340                    }
21341                    else if (layoutUuid.equals(StringPool.BLANK)) {
21342                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21343                    }
21344                    else {
21345                            bindLayoutUuid = true;
21346    
21347                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21348                    }
21349    
21350                    if (orderByComparator != null) {
21351                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21352    
21353                            if (orderByConditionFields.length > 0) {
21354                                    query.append(WHERE_AND);
21355                            }
21356    
21357                            for (int i = 0; i < orderByConditionFields.length; i++) {
21358                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21359                                    query.append(orderByConditionFields[i]);
21360    
21361                                    if ((i + 1) < orderByConditionFields.length) {
21362                                            if (orderByComparator.isAscending() ^ previous) {
21363                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21364                                            }
21365                                            else {
21366                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21367                                            }
21368                                    }
21369                                    else {
21370                                            if (orderByComparator.isAscending() ^ previous) {
21371                                                    query.append(WHERE_GREATER_THAN);
21372                                            }
21373                                            else {
21374                                                    query.append(WHERE_LESSER_THAN);
21375                                            }
21376                                    }
21377                            }
21378    
21379                            query.append(ORDER_BY_CLAUSE);
21380    
21381                            String[] orderByFields = orderByComparator.getOrderByFields();
21382    
21383                            for (int i = 0; i < orderByFields.length; i++) {
21384                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21385                                    query.append(orderByFields[i]);
21386    
21387                                    if ((i + 1) < orderByFields.length) {
21388                                            if (orderByComparator.isAscending() ^ previous) {
21389                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21390                                            }
21391                                            else {
21392                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21393                                            }
21394                                    }
21395                                    else {
21396                                            if (orderByComparator.isAscending() ^ previous) {
21397                                                    query.append(ORDER_BY_ASC);
21398                                            }
21399                                            else {
21400                                                    query.append(ORDER_BY_DESC);
21401                                            }
21402                                    }
21403                            }
21404                    }
21405                    else {
21406                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21407                    }
21408    
21409                    String sql = query.toString();
21410    
21411                    Query q = session.createQuery(sql);
21412    
21413                    q.setFirstResult(0);
21414                    q.setMaxResults(2);
21415    
21416                    QueryPos qPos = QueryPos.getInstance(q);
21417    
21418                    qPos.add(groupId);
21419    
21420                    qPos.add(classNameId);
21421    
21422                    if (bindLayoutUuid) {
21423                            qPos.add(layoutUuid);
21424                    }
21425    
21426                    if (orderByComparator != null) {
21427                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21428    
21429                            for (Object value : values) {
21430                                    qPos.add(value);
21431                            }
21432                    }
21433    
21434                    List<JournalArticle> list = q.list();
21435    
21436                    if (list.size() == 2) {
21437                            return list.get(1);
21438                    }
21439                    else {
21440                            return null;
21441                    }
21442            }
21443    
21444            /**
21445             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21446             *
21447             * @param groupId the group ID
21448             * @param classNameId the class name ID
21449             * @param layoutUuid the layout uuid
21450             * @return the matching journal articles that the user has permission to view
21451             * @throws SystemException if a system exception occurred
21452             */
21453            @Override
21454            public List<JournalArticle> filterFindByG_C_L(long groupId,
21455                    long classNameId, String layoutUuid) throws SystemException {
21456                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
21457                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21458            }
21459    
21460            /**
21461             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21462             *
21463             * <p>
21464             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21465             * </p>
21466             *
21467             * @param groupId the group ID
21468             * @param classNameId the class name ID
21469             * @param layoutUuid the layout uuid
21470             * @param start the lower bound of the range of journal articles
21471             * @param end the upper bound of the range of journal articles (not inclusive)
21472             * @return the range of matching journal articles that the user has permission to view
21473             * @throws SystemException if a system exception occurred
21474             */
21475            @Override
21476            public List<JournalArticle> filterFindByG_C_L(long groupId,
21477                    long classNameId, String layoutUuid, int start, int end)
21478                    throws SystemException {
21479                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
21480                            null);
21481            }
21482    
21483            /**
21484             * 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;.
21485             *
21486             * <p>
21487             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21488             * </p>
21489             *
21490             * @param groupId the group ID
21491             * @param classNameId the class name ID
21492             * @param layoutUuid the layout uuid
21493             * @param start the lower bound of the range of journal articles
21494             * @param end the upper bound of the range of journal articles (not inclusive)
21495             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21496             * @return the ordered range of matching journal articles that the user has permission to view
21497             * @throws SystemException if a system exception occurred
21498             */
21499            @Override
21500            public List<JournalArticle> filterFindByG_C_L(long groupId,
21501                    long classNameId, String layoutUuid, int start, int end,
21502                    OrderByComparator orderByComparator) throws SystemException {
21503                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21504                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
21505                                    orderByComparator);
21506                    }
21507    
21508                    StringBundler query = null;
21509    
21510                    if (orderByComparator != null) {
21511                            query = new StringBundler(5 +
21512                                            (orderByComparator.getOrderByFields().length * 3));
21513                    }
21514                    else {
21515                            query = new StringBundler(5);
21516                    }
21517    
21518                    if (getDB().isSupportsInlineDistinct()) {
21519                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21520                    }
21521                    else {
21522                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21523                    }
21524    
21525                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21526    
21527                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21528    
21529                    boolean bindLayoutUuid = false;
21530    
21531                    if (layoutUuid == null) {
21532                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21533                    }
21534                    else if (layoutUuid.equals(StringPool.BLANK)) {
21535                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21536                    }
21537                    else {
21538                            bindLayoutUuid = true;
21539    
21540                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21541                    }
21542    
21543                    if (!getDB().isSupportsInlineDistinct()) {
21544                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21545                    }
21546    
21547                    if (orderByComparator != null) {
21548                            if (getDB().isSupportsInlineDistinct()) {
21549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21550                                            orderByComparator, true);
21551                            }
21552                            else {
21553                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21554                                            orderByComparator, true);
21555                            }
21556                    }
21557                    else {
21558                            if (getDB().isSupportsInlineDistinct()) {
21559                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21560                            }
21561                            else {
21562                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21563                            }
21564                    }
21565    
21566                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21567                                    JournalArticle.class.getName(),
21568                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21569    
21570                    Session session = null;
21571    
21572                    try {
21573                            session = openSession();
21574    
21575                            SQLQuery q = session.createSQLQuery(sql);
21576    
21577                            if (getDB().isSupportsInlineDistinct()) {
21578                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21579                            }
21580                            else {
21581                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21582                            }
21583    
21584                            QueryPos qPos = QueryPos.getInstance(q);
21585    
21586                            qPos.add(groupId);
21587    
21588                            qPos.add(classNameId);
21589    
21590                            if (bindLayoutUuid) {
21591                                    qPos.add(layoutUuid);
21592                            }
21593    
21594                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21595                                    end);
21596                    }
21597                    catch (Exception e) {
21598                            throw processException(e);
21599                    }
21600                    finally {
21601                            closeSession(session);
21602                    }
21603            }
21604    
21605            /**
21606             * 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;.
21607             *
21608             * @param id the primary key of the current journal article
21609             * @param groupId the group ID
21610             * @param classNameId the class name ID
21611             * @param layoutUuid the layout uuid
21612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21613             * @return the previous, current, and next journal article
21614             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21615             * @throws SystemException if a system exception occurred
21616             */
21617            @Override
21618            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
21619                    long groupId, long classNameId, String layoutUuid,
21620                    OrderByComparator orderByComparator)
21621                    throws NoSuchArticleException, SystemException {
21622                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21623                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
21624                                    layoutUuid, orderByComparator);
21625                    }
21626    
21627                    JournalArticle journalArticle = findByPrimaryKey(id);
21628    
21629                    Session session = null;
21630    
21631                    try {
21632                            session = openSession();
21633    
21634                            JournalArticle[] array = new JournalArticleImpl[3];
21635    
21636                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
21637                                            groupId, classNameId, layoutUuid, orderByComparator, true);
21638    
21639                            array[1] = journalArticle;
21640    
21641                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
21642                                            groupId, classNameId, layoutUuid, orderByComparator, false);
21643    
21644                            return array;
21645                    }
21646                    catch (Exception e) {
21647                            throw processException(e);
21648                    }
21649                    finally {
21650                            closeSession(session);
21651                    }
21652            }
21653    
21654            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
21655                    JournalArticle journalArticle, long groupId, long classNameId,
21656                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
21657                    StringBundler query = null;
21658    
21659                    if (orderByComparator != null) {
21660                            query = new StringBundler(6 +
21661                                            (orderByComparator.getOrderByFields().length * 6));
21662                    }
21663                    else {
21664                            query = new StringBundler(3);
21665                    }
21666    
21667                    if (getDB().isSupportsInlineDistinct()) {
21668                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21669                    }
21670                    else {
21671                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21672                    }
21673    
21674                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21675    
21676                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21677    
21678                    boolean bindLayoutUuid = false;
21679    
21680                    if (layoutUuid == null) {
21681                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21682                    }
21683                    else if (layoutUuid.equals(StringPool.BLANK)) {
21684                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21685                    }
21686                    else {
21687                            bindLayoutUuid = true;
21688    
21689                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21690                    }
21691    
21692                    if (!getDB().isSupportsInlineDistinct()) {
21693                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21694                    }
21695    
21696                    if (orderByComparator != null) {
21697                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21698    
21699                            if (orderByConditionFields.length > 0) {
21700                                    query.append(WHERE_AND);
21701                            }
21702    
21703                            for (int i = 0; i < orderByConditionFields.length; i++) {
21704                                    if (getDB().isSupportsInlineDistinct()) {
21705                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21706                                    }
21707                                    else {
21708                                            query.append(_ORDER_BY_ENTITY_TABLE);
21709                                    }
21710    
21711                                    query.append(orderByConditionFields[i]);
21712    
21713                                    if ((i + 1) < orderByConditionFields.length) {
21714                                            if (orderByComparator.isAscending() ^ previous) {
21715                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21716                                            }
21717                                            else {
21718                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21719                                            }
21720                                    }
21721                                    else {
21722                                            if (orderByComparator.isAscending() ^ previous) {
21723                                                    query.append(WHERE_GREATER_THAN);
21724                                            }
21725                                            else {
21726                                                    query.append(WHERE_LESSER_THAN);
21727                                            }
21728                                    }
21729                            }
21730    
21731                            query.append(ORDER_BY_CLAUSE);
21732    
21733                            String[] orderByFields = orderByComparator.getOrderByFields();
21734    
21735                            for (int i = 0; i < orderByFields.length; i++) {
21736                                    if (getDB().isSupportsInlineDistinct()) {
21737                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21738                                    }
21739                                    else {
21740                                            query.append(_ORDER_BY_ENTITY_TABLE);
21741                                    }
21742    
21743                                    query.append(orderByFields[i]);
21744    
21745                                    if ((i + 1) < orderByFields.length) {
21746                                            if (orderByComparator.isAscending() ^ previous) {
21747                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21748                                            }
21749                                            else {
21750                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21751                                            }
21752                                    }
21753                                    else {
21754                                            if (orderByComparator.isAscending() ^ previous) {
21755                                                    query.append(ORDER_BY_ASC);
21756                                            }
21757                                            else {
21758                                                    query.append(ORDER_BY_DESC);
21759                                            }
21760                                    }
21761                            }
21762                    }
21763                    else {
21764                            if (getDB().isSupportsInlineDistinct()) {
21765                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21766                            }
21767                            else {
21768                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21769                            }
21770                    }
21771    
21772                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21773                                    JournalArticle.class.getName(),
21774                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21775    
21776                    SQLQuery q = session.createSQLQuery(sql);
21777    
21778                    q.setFirstResult(0);
21779                    q.setMaxResults(2);
21780    
21781                    if (getDB().isSupportsInlineDistinct()) {
21782                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21783                    }
21784                    else {
21785                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21786                    }
21787    
21788                    QueryPos qPos = QueryPos.getInstance(q);
21789    
21790                    qPos.add(groupId);
21791    
21792                    qPos.add(classNameId);
21793    
21794                    if (bindLayoutUuid) {
21795                            qPos.add(layoutUuid);
21796                    }
21797    
21798                    if (orderByComparator != null) {
21799                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21800    
21801                            for (Object value : values) {
21802                                    qPos.add(value);
21803                            }
21804                    }
21805    
21806                    List<JournalArticle> list = q.list();
21807    
21808                    if (list.size() == 2) {
21809                            return list.get(1);
21810                    }
21811                    else {
21812                            return null;
21813                    }
21814            }
21815    
21816            /**
21817             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
21818             *
21819             * @param groupId the group ID
21820             * @param classNameId the class name ID
21821             * @param layoutUuid the layout uuid
21822             * @throws SystemException if a system exception occurred
21823             */
21824            @Override
21825            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
21826                    throws SystemException {
21827                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
21828                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21829                            remove(journalArticle);
21830                    }
21831            }
21832    
21833            /**
21834             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21835             *
21836             * @param groupId the group ID
21837             * @param classNameId the class name ID
21838             * @param layoutUuid the layout uuid
21839             * @return the number of matching journal articles
21840             * @throws SystemException if a system exception occurred
21841             */
21842            @Override
21843            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
21844                    throws SystemException {
21845                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
21846    
21847                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
21848    
21849                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21850                                    this);
21851    
21852                    if (count == null) {
21853                            StringBundler query = new StringBundler(4);
21854    
21855                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21856    
21857                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21858    
21859                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21860    
21861                            boolean bindLayoutUuid = false;
21862    
21863                            if (layoutUuid == null) {
21864                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21865                            }
21866                            else if (layoutUuid.equals(StringPool.BLANK)) {
21867                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21868                            }
21869                            else {
21870                                    bindLayoutUuid = true;
21871    
21872                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21873                            }
21874    
21875                            String sql = query.toString();
21876    
21877                            Session session = null;
21878    
21879                            try {
21880                                    session = openSession();
21881    
21882                                    Query q = session.createQuery(sql);
21883    
21884                                    QueryPos qPos = QueryPos.getInstance(q);
21885    
21886                                    qPos.add(groupId);
21887    
21888                                    qPos.add(classNameId);
21889    
21890                                    if (bindLayoutUuid) {
21891                                            qPos.add(layoutUuid);
21892                                    }
21893    
21894                                    count = (Long)q.uniqueResult();
21895    
21896                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21897                            }
21898                            catch (Exception e) {
21899                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21900    
21901                                    throw processException(e);
21902                            }
21903                            finally {
21904                                    closeSession(session);
21905                            }
21906                    }
21907    
21908                    return count.intValue();
21909            }
21910    
21911            /**
21912             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
21913             *
21914             * @param groupId the group ID
21915             * @param classNameId the class name ID
21916             * @param layoutUuid the layout uuid
21917             * @return the number of matching journal articles that the user has permission to view
21918             * @throws SystemException if a system exception occurred
21919             */
21920            @Override
21921            public int filterCountByG_C_L(long groupId, long classNameId,
21922                    String layoutUuid) throws SystemException {
21923                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21924                            return countByG_C_L(groupId, classNameId, layoutUuid);
21925                    }
21926    
21927                    StringBundler query = new StringBundler(4);
21928    
21929                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21930    
21931                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
21932    
21933                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
21934    
21935                    boolean bindLayoutUuid = false;
21936    
21937                    if (layoutUuid == null) {
21938                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
21939                    }
21940                    else if (layoutUuid.equals(StringPool.BLANK)) {
21941                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
21942                    }
21943                    else {
21944                            bindLayoutUuid = true;
21945    
21946                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
21947                    }
21948    
21949                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21950                                    JournalArticle.class.getName(),
21951                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21952    
21953                    Session session = null;
21954    
21955                    try {
21956                            session = openSession();
21957    
21958                            SQLQuery q = session.createSQLQuery(sql);
21959    
21960                            q.addScalar(COUNT_COLUMN_NAME,
21961                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21962    
21963                            QueryPos qPos = QueryPos.getInstance(q);
21964    
21965                            qPos.add(groupId);
21966    
21967                            qPos.add(classNameId);
21968    
21969                            if (bindLayoutUuid) {
21970                                    qPos.add(layoutUuid);
21971                            }
21972    
21973                            Long count = (Long)q.uniqueResult();
21974    
21975                            return count.intValue();
21976                    }
21977                    catch (Exception e) {
21978                            throw processException(e);
21979                    }
21980                    finally {
21981                            closeSession(session);
21982                    }
21983            }
21984    
21985            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
21986            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
21987            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
21988            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
21989            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
21990            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21991                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21992                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
21993                            "findByG_U_C",
21994                            new String[] {
21995                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
21996                                    
21997                            Integer.class.getName(), Integer.class.getName(),
21998                                    OrderByComparator.class.getName()
21999                            });
22000            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22001                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22002                            JournalArticleImpl.class,
22003                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
22004                            new String[] {
22005                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
22006                            },
22007                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22008                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
22009                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22010                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22011                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22012            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22013                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22014                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
22015                            new String[] {
22016                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
22017                            });
22018    
22019            /**
22020             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22021             *
22022             * @param groupId the group ID
22023             * @param userId the user ID
22024             * @param classNameId the class name ID
22025             * @return the matching journal articles
22026             * @throws SystemException if a system exception occurred
22027             */
22028            @Override
22029            public List<JournalArticle> findByG_U_C(long groupId, long userId,
22030                    long classNameId) throws SystemException {
22031                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
22032                            QueryUtil.ALL_POS, null);
22033            }
22034    
22035            /**
22036             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22037             *
22038             * <p>
22039             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22040             * </p>
22041             *
22042             * @param groupId the group ID
22043             * @param userId the user ID
22044             * @param classNameId the class name ID
22045             * @param start the lower bound of the range of journal articles
22046             * @param end the upper bound of the range of journal articles (not inclusive)
22047             * @return the range of matching journal articles
22048             * @throws SystemException if a system exception occurred
22049             */
22050            @Override
22051            public List<JournalArticle> findByG_U_C(long groupId, long userId,
22052                    long classNameId, int start, int end) throws SystemException {
22053                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
22054            }
22055    
22056            /**
22057             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22058             *
22059             * <p>
22060             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22061             * </p>
22062             *
22063             * @param groupId the group ID
22064             * @param userId the user ID
22065             * @param classNameId the class name ID
22066             * @param start the lower bound of the range of journal articles
22067             * @param end the upper bound of the range of journal articles (not inclusive)
22068             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22069             * @return the ordered range of matching journal articles
22070             * @throws SystemException if a system exception occurred
22071             */
22072            @Override
22073            public List<JournalArticle> findByG_U_C(long groupId, long userId,
22074                    long classNameId, int start, int end,
22075                    OrderByComparator orderByComparator) throws SystemException {
22076                    boolean pagination = true;
22077                    FinderPath finderPath = null;
22078                    Object[] finderArgs = null;
22079    
22080                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22081                                    (orderByComparator == null)) {
22082                            pagination = false;
22083                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
22084                            finderArgs = new Object[] { groupId, userId, classNameId };
22085                    }
22086                    else {
22087                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
22088                            finderArgs = new Object[] {
22089                                            groupId, userId, classNameId,
22090                                            
22091                                            start, end, orderByComparator
22092                                    };
22093                    }
22094    
22095                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22096                                    finderArgs, this);
22097    
22098                    if ((list != null) && !list.isEmpty()) {
22099                            for (JournalArticle journalArticle : list) {
22100                                    if ((groupId != journalArticle.getGroupId()) ||
22101                                                    (userId != journalArticle.getUserId()) ||
22102                                                    (classNameId != journalArticle.getClassNameId())) {
22103                                            list = null;
22104    
22105                                            break;
22106                                    }
22107                            }
22108                    }
22109    
22110                    if (list == null) {
22111                            StringBundler query = null;
22112    
22113                            if (orderByComparator != null) {
22114                                    query = new StringBundler(5 +
22115                                                    (orderByComparator.getOrderByFields().length * 3));
22116                            }
22117                            else {
22118                                    query = new StringBundler(5);
22119                            }
22120    
22121                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22122    
22123                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22124    
22125                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22126    
22127                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22128    
22129                            if (orderByComparator != null) {
22130                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22131                                            orderByComparator);
22132                            }
22133                            else
22134                             if (pagination) {
22135                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22136                            }
22137    
22138                            String sql = query.toString();
22139    
22140                            Session session = null;
22141    
22142                            try {
22143                                    session = openSession();
22144    
22145                                    Query q = session.createQuery(sql);
22146    
22147                                    QueryPos qPos = QueryPos.getInstance(q);
22148    
22149                                    qPos.add(groupId);
22150    
22151                                    qPos.add(userId);
22152    
22153                                    qPos.add(classNameId);
22154    
22155                                    if (!pagination) {
22156                                            list = (List<JournalArticle>)QueryUtil.list(q,
22157                                                            getDialect(), start, end, false);
22158    
22159                                            Collections.sort(list);
22160    
22161                                            list = new UnmodifiableList<JournalArticle>(list);
22162                                    }
22163                                    else {
22164                                            list = (List<JournalArticle>)QueryUtil.list(q,
22165                                                            getDialect(), start, end);
22166                                    }
22167    
22168                                    cacheResult(list);
22169    
22170                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22171                            }
22172                            catch (Exception e) {
22173                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22174    
22175                                    throw processException(e);
22176                            }
22177                            finally {
22178                                    closeSession(session);
22179                            }
22180                    }
22181    
22182                    return list;
22183            }
22184    
22185            /**
22186             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22187             *
22188             * @param groupId the group ID
22189             * @param userId the user ID
22190             * @param classNameId the class name ID
22191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22192             * @return the first matching journal article
22193             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22194             * @throws SystemException if a system exception occurred
22195             */
22196            @Override
22197            public JournalArticle findByG_U_C_First(long groupId, long userId,
22198                    long classNameId, OrderByComparator orderByComparator)
22199                    throws NoSuchArticleException, SystemException {
22200                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
22201                                    classNameId, orderByComparator);
22202    
22203                    if (journalArticle != null) {
22204                            return journalArticle;
22205                    }
22206    
22207                    StringBundler msg = new StringBundler(8);
22208    
22209                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22210    
22211                    msg.append("groupId=");
22212                    msg.append(groupId);
22213    
22214                    msg.append(", userId=");
22215                    msg.append(userId);
22216    
22217                    msg.append(", classNameId=");
22218                    msg.append(classNameId);
22219    
22220                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22221    
22222                    throw new NoSuchArticleException(msg.toString());
22223            }
22224    
22225            /**
22226             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22227             *
22228             * @param groupId the group ID
22229             * @param userId the user ID
22230             * @param classNameId the class name ID
22231             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22232             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
22233             * @throws SystemException if a system exception occurred
22234             */
22235            @Override
22236            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
22237                    long classNameId, OrderByComparator orderByComparator)
22238                    throws SystemException {
22239                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
22240                                    0, 1, orderByComparator);
22241    
22242                    if (!list.isEmpty()) {
22243                            return list.get(0);
22244                    }
22245    
22246                    return null;
22247            }
22248    
22249            /**
22250             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22251             *
22252             * @param groupId the group ID
22253             * @param userId the user ID
22254             * @param classNameId the class name ID
22255             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22256             * @return the last matching journal article
22257             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22258             * @throws SystemException if a system exception occurred
22259             */
22260            @Override
22261            public JournalArticle findByG_U_C_Last(long groupId, long userId,
22262                    long classNameId, OrderByComparator orderByComparator)
22263                    throws NoSuchArticleException, SystemException {
22264                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
22265                                    classNameId, orderByComparator);
22266    
22267                    if (journalArticle != null) {
22268                            return journalArticle;
22269                    }
22270    
22271                    StringBundler msg = new StringBundler(8);
22272    
22273                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22274    
22275                    msg.append("groupId=");
22276                    msg.append(groupId);
22277    
22278                    msg.append(", userId=");
22279                    msg.append(userId);
22280    
22281                    msg.append(", classNameId=");
22282                    msg.append(classNameId);
22283    
22284                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22285    
22286                    throw new NoSuchArticleException(msg.toString());
22287            }
22288    
22289            /**
22290             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22291             *
22292             * @param groupId the group ID
22293             * @param userId the user ID
22294             * @param classNameId the class name ID
22295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22296             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
22297             * @throws SystemException if a system exception occurred
22298             */
22299            @Override
22300            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
22301                    long classNameId, OrderByComparator orderByComparator)
22302                    throws SystemException {
22303                    int count = countByG_U_C(groupId, userId, classNameId);
22304    
22305                    if (count == 0) {
22306                            return null;
22307                    }
22308    
22309                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
22310                                    count - 1, count, orderByComparator);
22311    
22312                    if (!list.isEmpty()) {
22313                            return list.get(0);
22314                    }
22315    
22316                    return null;
22317            }
22318    
22319            /**
22320             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22321             *
22322             * @param id the primary key of the current journal article
22323             * @param groupId the group ID
22324             * @param userId the user ID
22325             * @param classNameId the class name ID
22326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22327             * @return the previous, current, and next journal article
22328             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22329             * @throws SystemException if a system exception occurred
22330             */
22331            @Override
22332            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
22333                    long userId, long classNameId, OrderByComparator orderByComparator)
22334                    throws NoSuchArticleException, SystemException {
22335                    JournalArticle journalArticle = findByPrimaryKey(id);
22336    
22337                    Session session = null;
22338    
22339                    try {
22340                            session = openSession();
22341    
22342                            JournalArticle[] array = new JournalArticleImpl[3];
22343    
22344                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
22345                                            userId, classNameId, orderByComparator, true);
22346    
22347                            array[1] = journalArticle;
22348    
22349                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
22350                                            userId, classNameId, orderByComparator, false);
22351    
22352                            return array;
22353                    }
22354                    catch (Exception e) {
22355                            throw processException(e);
22356                    }
22357                    finally {
22358                            closeSession(session);
22359                    }
22360            }
22361    
22362            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
22363                    JournalArticle journalArticle, long groupId, long userId,
22364                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
22365                    StringBundler query = null;
22366    
22367                    if (orderByComparator != null) {
22368                            query = new StringBundler(6 +
22369                                            (orderByComparator.getOrderByFields().length * 6));
22370                    }
22371                    else {
22372                            query = new StringBundler(3);
22373                    }
22374    
22375                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22376    
22377                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22378    
22379                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22380    
22381                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22382    
22383                    if (orderByComparator != null) {
22384                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22385    
22386                            if (orderByConditionFields.length > 0) {
22387                                    query.append(WHERE_AND);
22388                            }
22389    
22390                            for (int i = 0; i < orderByConditionFields.length; i++) {
22391                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22392                                    query.append(orderByConditionFields[i]);
22393    
22394                                    if ((i + 1) < orderByConditionFields.length) {
22395                                            if (orderByComparator.isAscending() ^ previous) {
22396                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22397                                            }
22398                                            else {
22399                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22400                                            }
22401                                    }
22402                                    else {
22403                                            if (orderByComparator.isAscending() ^ previous) {
22404                                                    query.append(WHERE_GREATER_THAN);
22405                                            }
22406                                            else {
22407                                                    query.append(WHERE_LESSER_THAN);
22408                                            }
22409                                    }
22410                            }
22411    
22412                            query.append(ORDER_BY_CLAUSE);
22413    
22414                            String[] orderByFields = orderByComparator.getOrderByFields();
22415    
22416                            for (int i = 0; i < orderByFields.length; i++) {
22417                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22418                                    query.append(orderByFields[i]);
22419    
22420                                    if ((i + 1) < orderByFields.length) {
22421                                            if (orderByComparator.isAscending() ^ previous) {
22422                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22423                                            }
22424                                            else {
22425                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22426                                            }
22427                                    }
22428                                    else {
22429                                            if (orderByComparator.isAscending() ^ previous) {
22430                                                    query.append(ORDER_BY_ASC);
22431                                            }
22432                                            else {
22433                                                    query.append(ORDER_BY_DESC);
22434                                            }
22435                                    }
22436                            }
22437                    }
22438                    else {
22439                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22440                    }
22441    
22442                    String sql = query.toString();
22443    
22444                    Query q = session.createQuery(sql);
22445    
22446                    q.setFirstResult(0);
22447                    q.setMaxResults(2);
22448    
22449                    QueryPos qPos = QueryPos.getInstance(q);
22450    
22451                    qPos.add(groupId);
22452    
22453                    qPos.add(userId);
22454    
22455                    qPos.add(classNameId);
22456    
22457                    if (orderByComparator != null) {
22458                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22459    
22460                            for (Object value : values) {
22461                                    qPos.add(value);
22462                            }
22463                    }
22464    
22465                    List<JournalArticle> list = q.list();
22466    
22467                    if (list.size() == 2) {
22468                            return list.get(1);
22469                    }
22470                    else {
22471                            return null;
22472                    }
22473            }
22474    
22475            /**
22476             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22477             *
22478             * @param groupId the group ID
22479             * @param userId the user ID
22480             * @param classNameId the class name ID
22481             * @return the matching journal articles that the user has permission to view
22482             * @throws SystemException if a system exception occurred
22483             */
22484            @Override
22485            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
22486                    long classNameId) throws SystemException {
22487                    return filterFindByG_U_C(groupId, userId, classNameId,
22488                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22489            }
22490    
22491            /**
22492             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22493             *
22494             * <p>
22495             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22496             * </p>
22497             *
22498             * @param groupId the group ID
22499             * @param userId the user ID
22500             * @param classNameId the class name ID
22501             * @param start the lower bound of the range of journal articles
22502             * @param end the upper bound of the range of journal articles (not inclusive)
22503             * @return the range of matching journal articles that the user has permission to view
22504             * @throws SystemException if a system exception occurred
22505             */
22506            @Override
22507            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
22508                    long classNameId, int start, int end) throws SystemException {
22509                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
22510            }
22511    
22512            /**
22513             * 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;.
22514             *
22515             * <p>
22516             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22517             * </p>
22518             *
22519             * @param groupId the group ID
22520             * @param userId the user ID
22521             * @param classNameId the class name ID
22522             * @param start the lower bound of the range of journal articles
22523             * @param end the upper bound of the range of journal articles (not inclusive)
22524             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22525             * @return the ordered range of matching journal articles that the user has permission to view
22526             * @throws SystemException if a system exception occurred
22527             */
22528            @Override
22529            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
22530                    long classNameId, int start, int end,
22531                    OrderByComparator orderByComparator) throws SystemException {
22532                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22533                            return findByG_U_C(groupId, userId, classNameId, start, end,
22534                                    orderByComparator);
22535                    }
22536    
22537                    StringBundler query = null;
22538    
22539                    if (orderByComparator != null) {
22540                            query = new StringBundler(5 +
22541                                            (orderByComparator.getOrderByFields().length * 3));
22542                    }
22543                    else {
22544                            query = new StringBundler(5);
22545                    }
22546    
22547                    if (getDB().isSupportsInlineDistinct()) {
22548                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22549                    }
22550                    else {
22551                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22552                    }
22553    
22554                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22555    
22556                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22557    
22558                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22559    
22560                    if (!getDB().isSupportsInlineDistinct()) {
22561                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22562                    }
22563    
22564                    if (orderByComparator != null) {
22565                            if (getDB().isSupportsInlineDistinct()) {
22566                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22567                                            orderByComparator, true);
22568                            }
22569                            else {
22570                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22571                                            orderByComparator, true);
22572                            }
22573                    }
22574                    else {
22575                            if (getDB().isSupportsInlineDistinct()) {
22576                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22577                            }
22578                            else {
22579                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22580                            }
22581                    }
22582    
22583                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22584                                    JournalArticle.class.getName(),
22585                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22586    
22587                    Session session = null;
22588    
22589                    try {
22590                            session = openSession();
22591    
22592                            SQLQuery q = session.createSQLQuery(sql);
22593    
22594                            if (getDB().isSupportsInlineDistinct()) {
22595                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22596                            }
22597                            else {
22598                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22599                            }
22600    
22601                            QueryPos qPos = QueryPos.getInstance(q);
22602    
22603                            qPos.add(groupId);
22604    
22605                            qPos.add(userId);
22606    
22607                            qPos.add(classNameId);
22608    
22609                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22610                                    end);
22611                    }
22612                    catch (Exception e) {
22613                            throw processException(e);
22614                    }
22615                    finally {
22616                            closeSession(session);
22617                    }
22618            }
22619    
22620            /**
22621             * 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;.
22622             *
22623             * @param id the primary key of the current journal article
22624             * @param groupId the group ID
22625             * @param userId the user ID
22626             * @param classNameId the class name ID
22627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22628             * @return the previous, current, and next journal article
22629             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22630             * @throws SystemException if a system exception occurred
22631             */
22632            @Override
22633            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
22634                    long groupId, long userId, long classNameId,
22635                    OrderByComparator orderByComparator)
22636                    throws NoSuchArticleException, SystemException {
22637                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22638                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
22639                                    orderByComparator);
22640                    }
22641    
22642                    JournalArticle journalArticle = findByPrimaryKey(id);
22643    
22644                    Session session = null;
22645    
22646                    try {
22647                            session = openSession();
22648    
22649                            JournalArticle[] array = new JournalArticleImpl[3];
22650    
22651                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
22652                                            groupId, userId, classNameId, orderByComparator, true);
22653    
22654                            array[1] = journalArticle;
22655    
22656                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
22657                                            groupId, userId, classNameId, orderByComparator, false);
22658    
22659                            return array;
22660                    }
22661                    catch (Exception e) {
22662                            throw processException(e);
22663                    }
22664                    finally {
22665                            closeSession(session);
22666                    }
22667            }
22668    
22669            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
22670                    JournalArticle journalArticle, long groupId, long userId,
22671                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
22672                    StringBundler query = null;
22673    
22674                    if (orderByComparator != null) {
22675                            query = new StringBundler(6 +
22676                                            (orderByComparator.getOrderByFields().length * 6));
22677                    }
22678                    else {
22679                            query = new StringBundler(3);
22680                    }
22681    
22682                    if (getDB().isSupportsInlineDistinct()) {
22683                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22684                    }
22685                    else {
22686                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22687                    }
22688    
22689                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22690    
22691                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22692    
22693                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22694    
22695                    if (!getDB().isSupportsInlineDistinct()) {
22696                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22697                    }
22698    
22699                    if (orderByComparator != null) {
22700                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22701    
22702                            if (orderByConditionFields.length > 0) {
22703                                    query.append(WHERE_AND);
22704                            }
22705    
22706                            for (int i = 0; i < orderByConditionFields.length; i++) {
22707                                    if (getDB().isSupportsInlineDistinct()) {
22708                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22709                                    }
22710                                    else {
22711                                            query.append(_ORDER_BY_ENTITY_TABLE);
22712                                    }
22713    
22714                                    query.append(orderByConditionFields[i]);
22715    
22716                                    if ((i + 1) < orderByConditionFields.length) {
22717                                            if (orderByComparator.isAscending() ^ previous) {
22718                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22719                                            }
22720                                            else {
22721                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22722                                            }
22723                                    }
22724                                    else {
22725                                            if (orderByComparator.isAscending() ^ previous) {
22726                                                    query.append(WHERE_GREATER_THAN);
22727                                            }
22728                                            else {
22729                                                    query.append(WHERE_LESSER_THAN);
22730                                            }
22731                                    }
22732                            }
22733    
22734                            query.append(ORDER_BY_CLAUSE);
22735    
22736                            String[] orderByFields = orderByComparator.getOrderByFields();
22737    
22738                            for (int i = 0; i < orderByFields.length; i++) {
22739                                    if (getDB().isSupportsInlineDistinct()) {
22740                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22741                                    }
22742                                    else {
22743                                            query.append(_ORDER_BY_ENTITY_TABLE);
22744                                    }
22745    
22746                                    query.append(orderByFields[i]);
22747    
22748                                    if ((i + 1) < orderByFields.length) {
22749                                            if (orderByComparator.isAscending() ^ previous) {
22750                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22751                                            }
22752                                            else {
22753                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22754                                            }
22755                                    }
22756                                    else {
22757                                            if (orderByComparator.isAscending() ^ previous) {
22758                                                    query.append(ORDER_BY_ASC);
22759                                            }
22760                                            else {
22761                                                    query.append(ORDER_BY_DESC);
22762                                            }
22763                                    }
22764                            }
22765                    }
22766                    else {
22767                            if (getDB().isSupportsInlineDistinct()) {
22768                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22769                            }
22770                            else {
22771                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22772                            }
22773                    }
22774    
22775                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22776                                    JournalArticle.class.getName(),
22777                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22778    
22779                    SQLQuery q = session.createSQLQuery(sql);
22780    
22781                    q.setFirstResult(0);
22782                    q.setMaxResults(2);
22783    
22784                    if (getDB().isSupportsInlineDistinct()) {
22785                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22786                    }
22787                    else {
22788                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22789                    }
22790    
22791                    QueryPos qPos = QueryPos.getInstance(q);
22792    
22793                    qPos.add(groupId);
22794    
22795                    qPos.add(userId);
22796    
22797                    qPos.add(classNameId);
22798    
22799                    if (orderByComparator != null) {
22800                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22801    
22802                            for (Object value : values) {
22803                                    qPos.add(value);
22804                            }
22805                    }
22806    
22807                    List<JournalArticle> list = q.list();
22808    
22809                    if (list.size() == 2) {
22810                            return list.get(1);
22811                    }
22812                    else {
22813                            return null;
22814                    }
22815            }
22816    
22817            /**
22818             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
22819             *
22820             * @param groupId the group ID
22821             * @param userId the user ID
22822             * @param classNameId the class name ID
22823             * @throws SystemException if a system exception occurred
22824             */
22825            @Override
22826            public void removeByG_U_C(long groupId, long userId, long classNameId)
22827                    throws SystemException {
22828                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
22829                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22830                            remove(journalArticle);
22831                    }
22832            }
22833    
22834            /**
22835             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22836             *
22837             * @param groupId the group ID
22838             * @param userId the user ID
22839             * @param classNameId the class name ID
22840             * @return the number of matching journal articles
22841             * @throws SystemException if a system exception occurred
22842             */
22843            @Override
22844            public int countByG_U_C(long groupId, long userId, long classNameId)
22845                    throws SystemException {
22846                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
22847    
22848                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
22849    
22850                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22851                                    this);
22852    
22853                    if (count == null) {
22854                            StringBundler query = new StringBundler(4);
22855    
22856                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22857    
22858                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22859    
22860                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22861    
22862                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22863    
22864                            String sql = query.toString();
22865    
22866                            Session session = null;
22867    
22868                            try {
22869                                    session = openSession();
22870    
22871                                    Query q = session.createQuery(sql);
22872    
22873                                    QueryPos qPos = QueryPos.getInstance(q);
22874    
22875                                    qPos.add(groupId);
22876    
22877                                    qPos.add(userId);
22878    
22879                                    qPos.add(classNameId);
22880    
22881                                    count = (Long)q.uniqueResult();
22882    
22883                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22884                            }
22885                            catch (Exception e) {
22886                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22887    
22888                                    throw processException(e);
22889                            }
22890                            finally {
22891                                    closeSession(session);
22892                            }
22893                    }
22894    
22895                    return count.intValue();
22896            }
22897    
22898            /**
22899             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
22900             *
22901             * @param groupId the group ID
22902             * @param userId the user ID
22903             * @param classNameId the class name ID
22904             * @return the number of matching journal articles that the user has permission to view
22905             * @throws SystemException if a system exception occurred
22906             */
22907            @Override
22908            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
22909                    throws SystemException {
22910                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22911                            return countByG_U_C(groupId, userId, classNameId);
22912                    }
22913    
22914                    StringBundler query = new StringBundler(4);
22915    
22916                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22917    
22918                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
22919    
22920                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
22921    
22922                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
22923    
22924                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22925                                    JournalArticle.class.getName(),
22926                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22927    
22928                    Session session = null;
22929    
22930                    try {
22931                            session = openSession();
22932    
22933                            SQLQuery q = session.createSQLQuery(sql);
22934    
22935                            q.addScalar(COUNT_COLUMN_NAME,
22936                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22937    
22938                            QueryPos qPos = QueryPos.getInstance(q);
22939    
22940                            qPos.add(groupId);
22941    
22942                            qPos.add(userId);
22943    
22944                            qPos.add(classNameId);
22945    
22946                            Long count = (Long)q.uniqueResult();
22947    
22948                            return count.intValue();
22949                    }
22950                    catch (Exception e) {
22951                            throw processException(e);
22952                    }
22953                    finally {
22954                            closeSession(session);
22955                    }
22956            }
22957    
22958            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
22959            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
22960            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
22961            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22962                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22963                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
22964                            new String[] {
22965                                    Long.class.getName(), String.class.getName(),
22966                                    Double.class.getName()
22967                            },
22968                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22969                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22970                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22971            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22972                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22973                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
22974                            new String[] {
22975                                    Long.class.getName(), String.class.getName(),
22976                                    Double.class.getName()
22977                            });
22978    
22979            /**
22980             * 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.
22981             *
22982             * @param groupId the group ID
22983             * @param articleId the article ID
22984             * @param version the version
22985             * @return the matching journal article
22986             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22987             * @throws SystemException if a system exception occurred
22988             */
22989            @Override
22990            public JournalArticle findByG_A_V(long groupId, String articleId,
22991                    double version) throws NoSuchArticleException, SystemException {
22992                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
22993    
22994                    if (journalArticle == null) {
22995                            StringBundler msg = new StringBundler(8);
22996    
22997                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22998    
22999                            msg.append("groupId=");
23000                            msg.append(groupId);
23001    
23002                            msg.append(", articleId=");
23003                            msg.append(articleId);
23004    
23005                            msg.append(", version=");
23006                            msg.append(version);
23007    
23008                            msg.append(StringPool.CLOSE_CURLY_BRACE);
23009    
23010                            if (_log.isWarnEnabled()) {
23011                                    _log.warn(msg.toString());
23012                            }
23013    
23014                            throw new NoSuchArticleException(msg.toString());
23015                    }
23016    
23017                    return journalArticle;
23018            }
23019    
23020            /**
23021             * 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.
23022             *
23023             * @param groupId the group ID
23024             * @param articleId the article ID
23025             * @param version the version
23026             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
23027             * @throws SystemException if a system exception occurred
23028             */
23029            @Override
23030            public JournalArticle fetchByG_A_V(long groupId, String articleId,
23031                    double version) throws SystemException {
23032                    return fetchByG_A_V(groupId, articleId, version, true);
23033            }
23034    
23035            /**
23036             * 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.
23037             *
23038             * @param groupId the group ID
23039             * @param articleId the article ID
23040             * @param version the version
23041             * @param retrieveFromCache whether to use the finder cache
23042             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
23043             * @throws SystemException if a system exception occurred
23044             */
23045            @Override
23046            public JournalArticle fetchByG_A_V(long groupId, String articleId,
23047                    double version, boolean retrieveFromCache) throws SystemException {
23048                    Object[] finderArgs = new Object[] { groupId, articleId, version };
23049    
23050                    Object result = null;
23051    
23052                    if (retrieveFromCache) {
23053                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
23054                                            finderArgs, this);
23055                    }
23056    
23057                    if (result instanceof JournalArticle) {
23058                            JournalArticle journalArticle = (JournalArticle)result;
23059    
23060                            if ((groupId != journalArticle.getGroupId()) ||
23061                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
23062                                            (version != journalArticle.getVersion())) {
23063                                    result = null;
23064                            }
23065                    }
23066    
23067                    if (result == null) {
23068                            StringBundler query = new StringBundler(5);
23069    
23070                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23071    
23072                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
23073    
23074                            boolean bindArticleId = false;
23075    
23076                            if (articleId == null) {
23077                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
23078                            }
23079                            else if (articleId.equals(StringPool.BLANK)) {
23080                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
23081                            }
23082                            else {
23083                                    bindArticleId = true;
23084    
23085                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
23086                            }
23087    
23088                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
23089    
23090                            String sql = query.toString();
23091    
23092                            Session session = null;
23093    
23094                            try {
23095                                    session = openSession();
23096    
23097                                    Query q = session.createQuery(sql);
23098    
23099                                    QueryPos qPos = QueryPos.getInstance(q);
23100    
23101                                    qPos.add(groupId);
23102    
23103                                    if (bindArticleId) {
23104                                            qPos.add(articleId);
23105                                    }
23106    
23107                                    qPos.add(version);
23108    
23109                                    List<JournalArticle> list = q.list();
23110    
23111                                    if (list.isEmpty()) {
23112                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
23113                                                    finderArgs, list);
23114                                    }
23115                                    else {
23116                                            JournalArticle journalArticle = list.get(0);
23117    
23118                                            result = journalArticle;
23119    
23120                                            cacheResult(journalArticle);
23121    
23122                                            if ((journalArticle.getGroupId() != groupId) ||
23123                                                            (journalArticle.getArticleId() == null) ||
23124                                                            !journalArticle.getArticleId().equals(articleId) ||
23125                                                            (journalArticle.getVersion() != version)) {
23126                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
23127                                                            finderArgs, journalArticle);
23128                                            }
23129                                    }
23130                            }
23131                            catch (Exception e) {
23132                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
23133                                            finderArgs);
23134    
23135                                    throw processException(e);
23136                            }
23137                            finally {
23138                                    closeSession(session);
23139                            }
23140                    }
23141    
23142                    if (result instanceof List<?>) {
23143                            return null;
23144                    }
23145                    else {
23146                            return (JournalArticle)result;
23147                    }
23148            }
23149    
23150            /**
23151             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
23152             *
23153             * @param groupId the group ID
23154             * @param articleId the article ID
23155             * @param version the version
23156             * @return the journal article that was removed
23157             * @throws SystemException if a system exception occurred
23158             */
23159            @Override
23160            public JournalArticle removeByG_A_V(long groupId, String articleId,
23161                    double version) throws NoSuchArticleException, SystemException {
23162                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
23163    
23164                    return remove(journalArticle);
23165            }
23166    
23167            /**
23168             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
23169             *
23170             * @param groupId the group ID
23171             * @param articleId the article ID
23172             * @param version the version
23173             * @return the number of matching journal articles
23174             * @throws SystemException if a system exception occurred
23175             */
23176            @Override
23177            public int countByG_A_V(long groupId, String articleId, double version)
23178                    throws SystemException {
23179                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
23180    
23181                    Object[] finderArgs = new Object[] { groupId, articleId, version };
23182    
23183                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23184                                    this);
23185    
23186                    if (count == null) {
23187                            StringBundler query = new StringBundler(4);
23188    
23189                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23190    
23191                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
23192    
23193                            boolean bindArticleId = false;
23194    
23195                            if (articleId == null) {
23196                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
23197                            }
23198                            else if (articleId.equals(StringPool.BLANK)) {
23199                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
23200                            }
23201                            else {
23202                                    bindArticleId = true;
23203    
23204                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
23205                            }
23206    
23207                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
23208    
23209                            String sql = query.toString();
23210    
23211                            Session session = null;
23212    
23213                            try {
23214                                    session = openSession();
23215    
23216                                    Query q = session.createQuery(sql);
23217    
23218                                    QueryPos qPos = QueryPos.getInstance(q);
23219    
23220                                    qPos.add(groupId);
23221    
23222                                    if (bindArticleId) {
23223                                            qPos.add(articleId);
23224                                    }
23225    
23226                                    qPos.add(version);
23227    
23228                                    count = (Long)q.uniqueResult();
23229    
23230                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23231                            }
23232                            catch (Exception e) {
23233                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23234    
23235                                    throw processException(e);
23236                            }
23237                            finally {
23238                                    closeSession(session);
23239                            }
23240                    }
23241    
23242                    return count.intValue();
23243            }
23244    
23245            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
23246            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
23247            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
23248            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
23249            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
23250            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23251                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23252                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23253                            "findByG_A_ST",
23254                            new String[] {
23255                                    Long.class.getName(), String.class.getName(),
23256                                    Integer.class.getName(),
23257                                    
23258                            Integer.class.getName(), Integer.class.getName(),
23259                                    OrderByComparator.class.getName()
23260                            });
23261            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
23262                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23263                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23264                            JournalArticleImpl.class,
23265                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
23266                            new String[] {
23267                                    Long.class.getName(), String.class.getName(),
23268                                    Integer.class.getName()
23269                            },
23270                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23271                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23272                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
23273                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23274            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23275                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23276                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
23277                            new String[] {
23278                                    Long.class.getName(), String.class.getName(),
23279                                    Integer.class.getName()
23280                            });
23281            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23282                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23283                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
23284                            new String[] {
23285                                    Long.class.getName(), String.class.getName(),
23286                                    Integer.class.getName()
23287                            });
23288    
23289            /**
23290             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23291             *
23292             * @param groupId the group ID
23293             * @param articleId the article ID
23294             * @param status the status
23295             * @return the matching journal articles
23296             * @throws SystemException if a system exception occurred
23297             */
23298            @Override
23299            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23300                    int status) throws SystemException {
23301                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
23302                            QueryUtil.ALL_POS, null);
23303            }
23304    
23305            /**
23306             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23307             *
23308             * <p>
23309             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23310             * </p>
23311             *
23312             * @param groupId the group ID
23313             * @param articleId the article ID
23314             * @param status the status
23315             * @param start the lower bound of the range of journal articles
23316             * @param end the upper bound of the range of journal articles (not inclusive)
23317             * @return the range of matching journal articles
23318             * @throws SystemException if a system exception occurred
23319             */
23320            @Override
23321            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23322                    int status, int start, int end) throws SystemException {
23323                    return findByG_A_ST(groupId, articleId, status, start, end, null);
23324            }
23325    
23326            /**
23327             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23328             *
23329             * <p>
23330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23331             * </p>
23332             *
23333             * @param groupId the group ID
23334             * @param articleId the article ID
23335             * @param status the status
23336             * @param start the lower bound of the range of journal articles
23337             * @param end the upper bound of the range of journal articles (not inclusive)
23338             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23339             * @return the ordered range of matching journal articles
23340             * @throws SystemException if a system exception occurred
23341             */
23342            @Override
23343            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23344                    int status, int start, int end, OrderByComparator orderByComparator)
23345                    throws SystemException {
23346                    boolean pagination = true;
23347                    FinderPath finderPath = null;
23348                    Object[] finderArgs = null;
23349    
23350                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23351                                    (orderByComparator == null)) {
23352                            pagination = false;
23353                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
23354                            finderArgs = new Object[] { groupId, articleId, status };
23355                    }
23356                    else {
23357                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
23358                            finderArgs = new Object[] {
23359                                            groupId, articleId, status,
23360                                            
23361                                            start, end, orderByComparator
23362                                    };
23363                    }
23364    
23365                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23366                                    finderArgs, this);
23367    
23368                    if ((list != null) && !list.isEmpty()) {
23369                            for (JournalArticle journalArticle : list) {
23370                                    if ((groupId != journalArticle.getGroupId()) ||
23371                                                    !Validator.equals(articleId,
23372                                                            journalArticle.getArticleId()) ||
23373                                                    (status != journalArticle.getStatus())) {
23374                                            list = null;
23375    
23376                                            break;
23377                                    }
23378                            }
23379                    }
23380    
23381                    if (list == null) {
23382                            StringBundler query = null;
23383    
23384                            if (orderByComparator != null) {
23385                                    query = new StringBundler(5 +
23386                                                    (orderByComparator.getOrderByFields().length * 3));
23387                            }
23388                            else {
23389                                    query = new StringBundler(5);
23390                            }
23391    
23392                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23393    
23394                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23395    
23396                            boolean bindArticleId = false;
23397    
23398                            if (articleId == null) {
23399                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23400                            }
23401                            else if (articleId.equals(StringPool.BLANK)) {
23402                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23403                            }
23404                            else {
23405                                    bindArticleId = true;
23406    
23407                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23408                            }
23409    
23410                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23411    
23412                            if (orderByComparator != null) {
23413                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23414                                            orderByComparator);
23415                            }
23416                            else
23417                             if (pagination) {
23418                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23419                            }
23420    
23421                            String sql = query.toString();
23422    
23423                            Session session = null;
23424    
23425                            try {
23426                                    session = openSession();
23427    
23428                                    Query q = session.createQuery(sql);
23429    
23430                                    QueryPos qPos = QueryPos.getInstance(q);
23431    
23432                                    qPos.add(groupId);
23433    
23434                                    if (bindArticleId) {
23435                                            qPos.add(articleId);
23436                                    }
23437    
23438                                    qPos.add(status);
23439    
23440                                    if (!pagination) {
23441                                            list = (List<JournalArticle>)QueryUtil.list(q,
23442                                                            getDialect(), start, end, false);
23443    
23444                                            Collections.sort(list);
23445    
23446                                            list = new UnmodifiableList<JournalArticle>(list);
23447                                    }
23448                                    else {
23449                                            list = (List<JournalArticle>)QueryUtil.list(q,
23450                                                            getDialect(), start, end);
23451                                    }
23452    
23453                                    cacheResult(list);
23454    
23455                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23456                            }
23457                            catch (Exception e) {
23458                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23459    
23460                                    throw processException(e);
23461                            }
23462                            finally {
23463                                    closeSession(session);
23464                            }
23465                    }
23466    
23467                    return list;
23468            }
23469    
23470            /**
23471             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
23472             *
23473             * @param groupId the group ID
23474             * @param articleId the article ID
23475             * @param status the status
23476             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23477             * @return the first matching journal article
23478             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23479             * @throws SystemException if a system exception occurred
23480             */
23481            @Override
23482            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
23483                    int status, OrderByComparator orderByComparator)
23484                    throws NoSuchArticleException, SystemException {
23485                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
23486                                    status, orderByComparator);
23487    
23488                    if (journalArticle != null) {
23489                            return journalArticle;
23490                    }
23491    
23492                    StringBundler msg = new StringBundler(8);
23493    
23494                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23495    
23496                    msg.append("groupId=");
23497                    msg.append(groupId);
23498    
23499                    msg.append(", articleId=");
23500                    msg.append(articleId);
23501    
23502                    msg.append(", status=");
23503                    msg.append(status);
23504    
23505                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23506    
23507                    throw new NoSuchArticleException(msg.toString());
23508            }
23509    
23510            /**
23511             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
23512             *
23513             * @param groupId the group ID
23514             * @param articleId the article ID
23515             * @param status the status
23516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23517             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23518             * @throws SystemException if a system exception occurred
23519             */
23520            @Override
23521            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
23522                    int status, OrderByComparator orderByComparator)
23523                    throws SystemException {
23524                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
23525                                    1, orderByComparator);
23526    
23527                    if (!list.isEmpty()) {
23528                            return list.get(0);
23529                    }
23530    
23531                    return null;
23532            }
23533    
23534            /**
23535             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
23536             *
23537             * @param groupId the group ID
23538             * @param articleId the article ID
23539             * @param status the status
23540             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23541             * @return the last matching journal article
23542             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23543             * @throws SystemException if a system exception occurred
23544             */
23545            @Override
23546            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
23547                    int status, OrderByComparator orderByComparator)
23548                    throws NoSuchArticleException, SystemException {
23549                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
23550                                    status, orderByComparator);
23551    
23552                    if (journalArticle != null) {
23553                            return journalArticle;
23554                    }
23555    
23556                    StringBundler msg = new StringBundler(8);
23557    
23558                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23559    
23560                    msg.append("groupId=");
23561                    msg.append(groupId);
23562    
23563                    msg.append(", articleId=");
23564                    msg.append(articleId);
23565    
23566                    msg.append(", status=");
23567                    msg.append(status);
23568    
23569                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23570    
23571                    throw new NoSuchArticleException(msg.toString());
23572            }
23573    
23574            /**
23575             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
23576             *
23577             * @param groupId the group ID
23578             * @param articleId the article ID
23579             * @param status the status
23580             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23581             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23582             * @throws SystemException if a system exception occurred
23583             */
23584            @Override
23585            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
23586                    int status, OrderByComparator orderByComparator)
23587                    throws SystemException {
23588                    int count = countByG_A_ST(groupId, articleId, status);
23589    
23590                    if (count == 0) {
23591                            return null;
23592                    }
23593    
23594                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
23595                                    count - 1, count, orderByComparator);
23596    
23597                    if (!list.isEmpty()) {
23598                            return list.get(0);
23599                    }
23600    
23601                    return null;
23602            }
23603    
23604            /**
23605             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
23606             *
23607             * @param id the primary key of the current journal article
23608             * @param groupId the group ID
23609             * @param articleId the article ID
23610             * @param status the status
23611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23612             * @return the previous, current, and next journal article
23613             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23614             * @throws SystemException if a system exception occurred
23615             */
23616            @Override
23617            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
23618                    String articleId, int status, OrderByComparator orderByComparator)
23619                    throws NoSuchArticleException, SystemException {
23620                    JournalArticle journalArticle = findByPrimaryKey(id);
23621    
23622                    Session session = null;
23623    
23624                    try {
23625                            session = openSession();
23626    
23627                            JournalArticle[] array = new JournalArticleImpl[3];
23628    
23629                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
23630                                            groupId, articleId, status, orderByComparator, true);
23631    
23632                            array[1] = journalArticle;
23633    
23634                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
23635                                            groupId, articleId, status, orderByComparator, false);
23636    
23637                            return array;
23638                    }
23639                    catch (Exception e) {
23640                            throw processException(e);
23641                    }
23642                    finally {
23643                            closeSession(session);
23644                    }
23645            }
23646    
23647            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
23648                    JournalArticle journalArticle, long groupId, String articleId,
23649                    int status, OrderByComparator orderByComparator, boolean previous) {
23650                    StringBundler query = null;
23651    
23652                    if (orderByComparator != null) {
23653                            query = new StringBundler(6 +
23654                                            (orderByComparator.getOrderByFields().length * 6));
23655                    }
23656                    else {
23657                            query = new StringBundler(3);
23658                    }
23659    
23660                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23661    
23662                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23663    
23664                    boolean bindArticleId = false;
23665    
23666                    if (articleId == null) {
23667                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23668                    }
23669                    else if (articleId.equals(StringPool.BLANK)) {
23670                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23671                    }
23672                    else {
23673                            bindArticleId = true;
23674    
23675                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23676                    }
23677    
23678                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23679    
23680                    if (orderByComparator != null) {
23681                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23682    
23683                            if (orderByConditionFields.length > 0) {
23684                                    query.append(WHERE_AND);
23685                            }
23686    
23687                            for (int i = 0; i < orderByConditionFields.length; i++) {
23688                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23689                                    query.append(orderByConditionFields[i]);
23690    
23691                                    if ((i + 1) < orderByConditionFields.length) {
23692                                            if (orderByComparator.isAscending() ^ previous) {
23693                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23694                                            }
23695                                            else {
23696                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23697                                            }
23698                                    }
23699                                    else {
23700                                            if (orderByComparator.isAscending() ^ previous) {
23701                                                    query.append(WHERE_GREATER_THAN);
23702                                            }
23703                                            else {
23704                                                    query.append(WHERE_LESSER_THAN);
23705                                            }
23706                                    }
23707                            }
23708    
23709                            query.append(ORDER_BY_CLAUSE);
23710    
23711                            String[] orderByFields = orderByComparator.getOrderByFields();
23712    
23713                            for (int i = 0; i < orderByFields.length; i++) {
23714                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23715                                    query.append(orderByFields[i]);
23716    
23717                                    if ((i + 1) < orderByFields.length) {
23718                                            if (orderByComparator.isAscending() ^ previous) {
23719                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23720                                            }
23721                                            else {
23722                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23723                                            }
23724                                    }
23725                                    else {
23726                                            if (orderByComparator.isAscending() ^ previous) {
23727                                                    query.append(ORDER_BY_ASC);
23728                                            }
23729                                            else {
23730                                                    query.append(ORDER_BY_DESC);
23731                                            }
23732                                    }
23733                            }
23734                    }
23735                    else {
23736                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23737                    }
23738    
23739                    String sql = query.toString();
23740    
23741                    Query q = session.createQuery(sql);
23742    
23743                    q.setFirstResult(0);
23744                    q.setMaxResults(2);
23745    
23746                    QueryPos qPos = QueryPos.getInstance(q);
23747    
23748                    qPos.add(groupId);
23749    
23750                    if (bindArticleId) {
23751                            qPos.add(articleId);
23752                    }
23753    
23754                    qPos.add(status);
23755    
23756                    if (orderByComparator != null) {
23757                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23758    
23759                            for (Object value : values) {
23760                                    qPos.add(value);
23761                            }
23762                    }
23763    
23764                    List<JournalArticle> list = q.list();
23765    
23766                    if (list.size() == 2) {
23767                            return list.get(1);
23768                    }
23769                    else {
23770                            return null;
23771                    }
23772            }
23773    
23774            /**
23775             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
23776             *
23777             * @param groupId the group ID
23778             * @param articleId the article ID
23779             * @param status the status
23780             * @return the matching journal articles that the user has permission to view
23781             * @throws SystemException if a system exception occurred
23782             */
23783            @Override
23784            public List<JournalArticle> filterFindByG_A_ST(long groupId,
23785                    String articleId, int status) throws SystemException {
23786                    return filterFindByG_A_ST(groupId, articleId, status,
23787                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23788            }
23789    
23790            /**
23791             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
23792             *
23793             * <p>
23794             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23795             * </p>
23796             *
23797             * @param groupId the group ID
23798             * @param articleId the article ID
23799             * @param status the status
23800             * @param start the lower bound of the range of journal articles
23801             * @param end the upper bound of the range of journal articles (not inclusive)
23802             * @return the range of matching journal articles that the user has permission to view
23803             * @throws SystemException if a system exception occurred
23804             */
23805            @Override
23806            public List<JournalArticle> filterFindByG_A_ST(long groupId,
23807                    String articleId, int status, int start, int end)
23808                    throws SystemException {
23809                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
23810            }
23811    
23812            /**
23813             * 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;.
23814             *
23815             * <p>
23816             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23817             * </p>
23818             *
23819             * @param groupId the group ID
23820             * @param articleId the article ID
23821             * @param status the status
23822             * @param start the lower bound of the range of journal articles
23823             * @param end the upper bound of the range of journal articles (not inclusive)
23824             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23825             * @return the ordered range of matching journal articles that the user has permission to view
23826             * @throws SystemException if a system exception occurred
23827             */
23828            @Override
23829            public List<JournalArticle> filterFindByG_A_ST(long groupId,
23830                    String articleId, int status, int start, int end,
23831                    OrderByComparator orderByComparator) throws SystemException {
23832                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23833                            return findByG_A_ST(groupId, articleId, status, start, end,
23834                                    orderByComparator);
23835                    }
23836    
23837                    StringBundler query = null;
23838    
23839                    if (orderByComparator != null) {
23840                            query = new StringBundler(5 +
23841                                            (orderByComparator.getOrderByFields().length * 3));
23842                    }
23843                    else {
23844                            query = new StringBundler(5);
23845                    }
23846    
23847                    if (getDB().isSupportsInlineDistinct()) {
23848                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23849                    }
23850                    else {
23851                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23852                    }
23853    
23854                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23855    
23856                    boolean bindArticleId = false;
23857    
23858                    if (articleId == null) {
23859                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23860                    }
23861                    else if (articleId.equals(StringPool.BLANK)) {
23862                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23863                    }
23864                    else {
23865                            bindArticleId = true;
23866    
23867                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23868                    }
23869    
23870                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23871    
23872                    if (!getDB().isSupportsInlineDistinct()) {
23873                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23874                    }
23875    
23876                    if (orderByComparator != null) {
23877                            if (getDB().isSupportsInlineDistinct()) {
23878                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23879                                            orderByComparator, true);
23880                            }
23881                            else {
23882                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23883                                            orderByComparator, true);
23884                            }
23885                    }
23886                    else {
23887                            if (getDB().isSupportsInlineDistinct()) {
23888                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23889                            }
23890                            else {
23891                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23892                            }
23893                    }
23894    
23895                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23896                                    JournalArticle.class.getName(),
23897                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23898    
23899                    Session session = null;
23900    
23901                    try {
23902                            session = openSession();
23903    
23904                            SQLQuery q = session.createSQLQuery(sql);
23905    
23906                            if (getDB().isSupportsInlineDistinct()) {
23907                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23908                            }
23909                            else {
23910                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23911                            }
23912    
23913                            QueryPos qPos = QueryPos.getInstance(q);
23914    
23915                            qPos.add(groupId);
23916    
23917                            if (bindArticleId) {
23918                                    qPos.add(articleId);
23919                            }
23920    
23921                            qPos.add(status);
23922    
23923                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23924                                    end);
23925                    }
23926                    catch (Exception e) {
23927                            throw processException(e);
23928                    }
23929                    finally {
23930                            closeSession(session);
23931                    }
23932            }
23933    
23934            /**
23935             * 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;.
23936             *
23937             * @param id the primary key of the current journal article
23938             * @param groupId the group ID
23939             * @param articleId the article ID
23940             * @param status the status
23941             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23942             * @return the previous, current, and next journal article
23943             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23944             * @throws SystemException if a system exception occurred
23945             */
23946            @Override
23947            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
23948                    long groupId, String articleId, int status,
23949                    OrderByComparator orderByComparator)
23950                    throws NoSuchArticleException, SystemException {
23951                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23952                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
23953                                    orderByComparator);
23954                    }
23955    
23956                    JournalArticle journalArticle = findByPrimaryKey(id);
23957    
23958                    Session session = null;
23959    
23960                    try {
23961                            session = openSession();
23962    
23963                            JournalArticle[] array = new JournalArticleImpl[3];
23964    
23965                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
23966                                            groupId, articleId, status, orderByComparator, true);
23967    
23968                            array[1] = journalArticle;
23969    
23970                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
23971                                            groupId, articleId, status, orderByComparator, false);
23972    
23973                            return array;
23974                    }
23975                    catch (Exception e) {
23976                            throw processException(e);
23977                    }
23978                    finally {
23979                            closeSession(session);
23980                    }
23981            }
23982    
23983            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
23984                    JournalArticle journalArticle, long groupId, String articleId,
23985                    int status, OrderByComparator orderByComparator, boolean previous) {
23986                    StringBundler query = null;
23987    
23988                    if (orderByComparator != null) {
23989                            query = new StringBundler(6 +
23990                                            (orderByComparator.getOrderByFields().length * 6));
23991                    }
23992                    else {
23993                            query = new StringBundler(3);
23994                    }
23995    
23996                    if (getDB().isSupportsInlineDistinct()) {
23997                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23998                    }
23999                    else {
24000                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24001                    }
24002    
24003                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24004    
24005                    boolean bindArticleId = false;
24006    
24007                    if (articleId == null) {
24008                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24009                    }
24010                    else if (articleId.equals(StringPool.BLANK)) {
24011                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24012                    }
24013                    else {
24014                            bindArticleId = true;
24015    
24016                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24017                    }
24018    
24019                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24020    
24021                    if (!getDB().isSupportsInlineDistinct()) {
24022                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24023                    }
24024    
24025                    if (orderByComparator != null) {
24026                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24027    
24028                            if (orderByConditionFields.length > 0) {
24029                                    query.append(WHERE_AND);
24030                            }
24031    
24032                            for (int i = 0; i < orderByConditionFields.length; i++) {
24033                                    if (getDB().isSupportsInlineDistinct()) {
24034                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24035                                    }
24036                                    else {
24037                                            query.append(_ORDER_BY_ENTITY_TABLE);
24038                                    }
24039    
24040                                    query.append(orderByConditionFields[i]);
24041    
24042                                    if ((i + 1) < orderByConditionFields.length) {
24043                                            if (orderByComparator.isAscending() ^ previous) {
24044                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24045                                            }
24046                                            else {
24047                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24048                                            }
24049                                    }
24050                                    else {
24051                                            if (orderByComparator.isAscending() ^ previous) {
24052                                                    query.append(WHERE_GREATER_THAN);
24053                                            }
24054                                            else {
24055                                                    query.append(WHERE_LESSER_THAN);
24056                                            }
24057                                    }
24058                            }
24059    
24060                            query.append(ORDER_BY_CLAUSE);
24061    
24062                            String[] orderByFields = orderByComparator.getOrderByFields();
24063    
24064                            for (int i = 0; i < orderByFields.length; i++) {
24065                                    if (getDB().isSupportsInlineDistinct()) {
24066                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24067                                    }
24068                                    else {
24069                                            query.append(_ORDER_BY_ENTITY_TABLE);
24070                                    }
24071    
24072                                    query.append(orderByFields[i]);
24073    
24074                                    if ((i + 1) < orderByFields.length) {
24075                                            if (orderByComparator.isAscending() ^ previous) {
24076                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24077                                            }
24078                                            else {
24079                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24080                                            }
24081                                    }
24082                                    else {
24083                                            if (orderByComparator.isAscending() ^ previous) {
24084                                                    query.append(ORDER_BY_ASC);
24085                                            }
24086                                            else {
24087                                                    query.append(ORDER_BY_DESC);
24088                                            }
24089                                    }
24090                            }
24091                    }
24092                    else {
24093                            if (getDB().isSupportsInlineDistinct()) {
24094                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24095                            }
24096                            else {
24097                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24098                            }
24099                    }
24100    
24101                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24102                                    JournalArticle.class.getName(),
24103                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24104    
24105                    SQLQuery q = session.createSQLQuery(sql);
24106    
24107                    q.setFirstResult(0);
24108                    q.setMaxResults(2);
24109    
24110                    if (getDB().isSupportsInlineDistinct()) {
24111                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24112                    }
24113                    else {
24114                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24115                    }
24116    
24117                    QueryPos qPos = QueryPos.getInstance(q);
24118    
24119                    qPos.add(groupId);
24120    
24121                    if (bindArticleId) {
24122                            qPos.add(articleId);
24123                    }
24124    
24125                    qPos.add(status);
24126    
24127                    if (orderByComparator != null) {
24128                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24129    
24130                            for (Object value : values) {
24131                                    qPos.add(value);
24132                            }
24133                    }
24134    
24135                    List<JournalArticle> list = q.list();
24136    
24137                    if (list.size() == 2) {
24138                            return list.get(1);
24139                    }
24140                    else {
24141                            return null;
24142                    }
24143            }
24144    
24145            /**
24146             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
24147             *
24148             * @param groupId the group ID
24149             * @param articleId the article ID
24150             * @param statuses the statuses
24151             * @return the matching journal articles that the user has permission to view
24152             * @throws SystemException if a system exception occurred
24153             */
24154            @Override
24155            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24156                    String articleId, int[] statuses) throws SystemException {
24157                    return filterFindByG_A_ST(groupId, articleId, statuses,
24158                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24159            }
24160    
24161            /**
24162             * 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;.
24163             *
24164             * <p>
24165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24166             * </p>
24167             *
24168             * @param groupId the group ID
24169             * @param articleId the article ID
24170             * @param statuses the statuses
24171             * @param start the lower bound of the range of journal articles
24172             * @param end the upper bound of the range of journal articles (not inclusive)
24173             * @return the range of matching journal articles that the user has permission to view
24174             * @throws SystemException if a system exception occurred
24175             */
24176            @Override
24177            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24178                    String articleId, int[] statuses, int start, int end)
24179                    throws SystemException {
24180                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
24181            }
24182    
24183            /**
24184             * 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;.
24185             *
24186             * <p>
24187             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24188             * </p>
24189             *
24190             * @param groupId the group ID
24191             * @param articleId the article ID
24192             * @param statuses the statuses
24193             * @param start the lower bound of the range of journal articles
24194             * @param end the upper bound of the range of journal articles (not inclusive)
24195             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24196             * @return the ordered range of matching journal articles that the user has permission to view
24197             * @throws SystemException if a system exception occurred
24198             */
24199            @Override
24200            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24201                    String articleId, int[] statuses, int start, int end,
24202                    OrderByComparator orderByComparator) throws SystemException {
24203                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24204                            return findByG_A_ST(groupId, articleId, statuses, start, end,
24205                                    orderByComparator);
24206                    }
24207    
24208                    StringBundler query = new StringBundler();
24209    
24210                    if (getDB().isSupportsInlineDistinct()) {
24211                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24212                    }
24213                    else {
24214                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24215                    }
24216    
24217                    boolean conjunctionable = false;
24218    
24219                    if (conjunctionable) {
24220                            query.append(WHERE_AND);
24221                    }
24222    
24223                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
24224    
24225                    conjunctionable = true;
24226    
24227                    if (conjunctionable) {
24228                            query.append(WHERE_AND);
24229                    }
24230    
24231                    if (articleId == null) {
24232                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
24233                    }
24234                    else if (articleId.equals(StringPool.BLANK)) {
24235                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
24236                    }
24237                    else {
24238                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
24239                    }
24240    
24241                    conjunctionable = true;
24242    
24243                    if ((statuses == null) || (statuses.length > 0)) {
24244                            if (conjunctionable) {
24245                                    query.append(WHERE_AND);
24246                            }
24247    
24248                            query.append(StringPool.OPEN_PARENTHESIS);
24249    
24250                            for (int i = 0; i < statuses.length; i++) {
24251                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
24252    
24253                                    if ((i + 1) < statuses.length) {
24254                                            query.append(WHERE_OR);
24255                                    }
24256                            }
24257    
24258                            query.append(StringPool.CLOSE_PARENTHESIS);
24259    
24260                            conjunctionable = true;
24261                    }
24262    
24263                    if (!getDB().isSupportsInlineDistinct()) {
24264                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24265                    }
24266    
24267                    if (orderByComparator != null) {
24268                            if (getDB().isSupportsInlineDistinct()) {
24269                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24270                                            orderByComparator, true);
24271                            }
24272                            else {
24273                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24274                                            orderByComparator, true);
24275                            }
24276                    }
24277                    else {
24278                            if (getDB().isSupportsInlineDistinct()) {
24279                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24280                            }
24281                            else {
24282                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24283                            }
24284                    }
24285    
24286                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24287                                    JournalArticle.class.getName(),
24288                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24289    
24290                    Session session = null;
24291    
24292                    try {
24293                            session = openSession();
24294    
24295                            SQLQuery q = session.createSQLQuery(sql);
24296    
24297                            if (getDB().isSupportsInlineDistinct()) {
24298                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24299                            }
24300                            else {
24301                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24302                            }
24303    
24304                            QueryPos qPos = QueryPos.getInstance(q);
24305    
24306                            qPos.add(groupId);
24307    
24308                            if (articleId != null) {
24309                                    qPos.add(articleId);
24310                            }
24311    
24312                            if (statuses != null) {
24313                                    qPos.add(statuses);
24314                            }
24315    
24316                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24317                                    end);
24318                    }
24319                    catch (Exception e) {
24320                            throw processException(e);
24321                    }
24322                    finally {
24323                            closeSession(session);
24324                    }
24325            }
24326    
24327            /**
24328             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#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 statuses the statuses
24337             * @return the matching journal articles
24338             * @throws SystemException if a system exception occurred
24339             */
24340            @Override
24341            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24342                    int[] statuses) throws SystemException {
24343                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
24344                            QueryUtil.ALL_POS, null);
24345            }
24346    
24347            /**
24348             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
24349             *
24350             * <p>
24351             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24352             * </p>
24353             *
24354             * @param groupId the group ID
24355             * @param articleId the article ID
24356             * @param statuses the statuses
24357             * @param start the lower bound of the range of journal articles
24358             * @param end the upper bound of the range of journal articles (not inclusive)
24359             * @return the range of matching journal articles
24360             * @throws SystemException if a system exception occurred
24361             */
24362            @Override
24363            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24364                    int[] statuses, int start, int end) throws SystemException {
24365                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
24366            }
24367    
24368            /**
24369             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
24370             *
24371             * <p>
24372             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24373             * </p>
24374             *
24375             * @param groupId the group ID
24376             * @param articleId the article ID
24377             * @param statuses the statuses
24378             * @param start the lower bound of the range of journal articles
24379             * @param end the upper bound of the range of journal articles (not inclusive)
24380             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24381             * @return the ordered range of matching journal articles
24382             * @throws SystemException if a system exception occurred
24383             */
24384            @Override
24385            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24386                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
24387                    throws SystemException {
24388                    if ((statuses != null) && (statuses.length == 1)) {
24389                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
24390                                    orderByComparator);
24391                    }
24392    
24393                    boolean pagination = true;
24394                    Object[] finderArgs = null;
24395    
24396                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24397                                    (orderByComparator == null)) {
24398                            pagination = false;
24399                            finderArgs = new Object[] {
24400                                            groupId, articleId, StringUtil.merge(statuses)
24401                                    };
24402                    }
24403                    else {
24404                            finderArgs = new Object[] {
24405                                            groupId, articleId, StringUtil.merge(statuses),
24406                                            
24407                                            start, end, orderByComparator
24408                                    };
24409                    }
24410    
24411                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
24412                                    finderArgs, this);
24413    
24414                    if ((list != null) && !list.isEmpty()) {
24415                            for (JournalArticle journalArticle : list) {
24416                                    if ((groupId != journalArticle.getGroupId()) ||
24417                                                    !Validator.equals(articleId,
24418                                                            journalArticle.getArticleId()) ||
24419                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
24420                                            list = null;
24421    
24422                                            break;
24423                                    }
24424                            }
24425                    }
24426    
24427                    if (list == null) {
24428                            StringBundler query = new StringBundler();
24429    
24430                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24431    
24432                            boolean conjunctionable = false;
24433    
24434                            if (conjunctionable) {
24435                                    query.append(WHERE_AND);
24436                            }
24437    
24438                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
24439    
24440                            conjunctionable = true;
24441    
24442                            if (conjunctionable) {
24443                                    query.append(WHERE_AND);
24444                            }
24445    
24446                            if (articleId == null) {
24447                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
24448                            }
24449                            else if (articleId.equals(StringPool.BLANK)) {
24450                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
24451                            }
24452                            else {
24453                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
24454                            }
24455    
24456                            conjunctionable = true;
24457    
24458                            if ((statuses == null) || (statuses.length > 0)) {
24459                                    if (conjunctionable) {
24460                                            query.append(WHERE_AND);
24461                                    }
24462    
24463                                    query.append(StringPool.OPEN_PARENTHESIS);
24464    
24465                                    for (int i = 0; i < statuses.length; i++) {
24466                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
24467    
24468                                            if ((i + 1) < statuses.length) {
24469                                                    query.append(WHERE_OR);
24470                                            }
24471                                    }
24472    
24473                                    query.append(StringPool.CLOSE_PARENTHESIS);
24474    
24475                                    conjunctionable = true;
24476                            }
24477    
24478                            if (orderByComparator != null) {
24479                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24480                                            orderByComparator);
24481                            }
24482                            else
24483                             if (pagination) {
24484                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24485                            }
24486    
24487                            String sql = query.toString();
24488    
24489                            Session session = null;
24490    
24491                            try {
24492                                    session = openSession();
24493    
24494                                    Query q = session.createQuery(sql);
24495    
24496                                    QueryPos qPos = QueryPos.getInstance(q);
24497    
24498                                    qPos.add(groupId);
24499    
24500                                    if (articleId != null) {
24501                                            qPos.add(articleId);
24502                                    }
24503    
24504                                    if (statuses != null) {
24505                                            qPos.add(statuses);
24506                                    }
24507    
24508                                    if (!pagination) {
24509                                            list = (List<JournalArticle>)QueryUtil.list(q,
24510                                                            getDialect(), start, end, false);
24511    
24512                                            Collections.sort(list);
24513    
24514                                            list = new UnmodifiableList<JournalArticle>(list);
24515                                    }
24516                                    else {
24517                                            list = (List<JournalArticle>)QueryUtil.list(q,
24518                                                            getDialect(), start, end);
24519                                    }
24520    
24521                                    cacheResult(list);
24522    
24523                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
24524                                            finderArgs, list);
24525                            }
24526                            catch (Exception e) {
24527                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
24528                                            finderArgs);
24529    
24530                                    throw processException(e);
24531                            }
24532                            finally {
24533                                    closeSession(session);
24534                            }
24535                    }
24536    
24537                    return list;
24538            }
24539    
24540            /**
24541             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
24542             *
24543             * @param groupId the group ID
24544             * @param articleId the article ID
24545             * @param status the status
24546             * @throws SystemException if a system exception occurred
24547             */
24548            @Override
24549            public void removeByG_A_ST(long groupId, String articleId, int status)
24550                    throws SystemException {
24551                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
24552                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24553                            remove(journalArticle);
24554                    }
24555            }
24556    
24557            /**
24558             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24559             *
24560             * @param groupId the group ID
24561             * @param articleId the article ID
24562             * @param status the status
24563             * @return the number of matching journal articles
24564             * @throws SystemException if a system exception occurred
24565             */
24566            @Override
24567            public int countByG_A_ST(long groupId, String articleId, int status)
24568                    throws SystemException {
24569                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
24570    
24571                    Object[] finderArgs = new Object[] { groupId, articleId, status };
24572    
24573                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24574                                    this);
24575    
24576                    if (count == null) {
24577                            StringBundler query = new StringBundler(4);
24578    
24579                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24580    
24581                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24582    
24583                            boolean bindArticleId = false;
24584    
24585                            if (articleId == null) {
24586                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24587                            }
24588                            else if (articleId.equals(StringPool.BLANK)) {
24589                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24590                            }
24591                            else {
24592                                    bindArticleId = true;
24593    
24594                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24595                            }
24596    
24597                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24598    
24599                            String sql = query.toString();
24600    
24601                            Session session = null;
24602    
24603                            try {
24604                                    session = openSession();
24605    
24606                                    Query q = session.createQuery(sql);
24607    
24608                                    QueryPos qPos = QueryPos.getInstance(q);
24609    
24610                                    qPos.add(groupId);
24611    
24612                                    if (bindArticleId) {
24613                                            qPos.add(articleId);
24614                                    }
24615    
24616                                    qPos.add(status);
24617    
24618                                    count = (Long)q.uniqueResult();
24619    
24620                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24621                            }
24622                            catch (Exception e) {
24623                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24624    
24625                                    throw processException(e);
24626                            }
24627                            finally {
24628                                    closeSession(session);
24629                            }
24630                    }
24631    
24632                    return count.intValue();
24633            }
24634    
24635            /**
24636             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
24637             *
24638             * @param groupId the group ID
24639             * @param articleId the article ID
24640             * @param statuses the statuses
24641             * @return the number of matching journal articles
24642             * @throws SystemException if a system exception occurred
24643             */
24644            @Override
24645            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
24646                    throws SystemException {
24647                    Object[] finderArgs = new Object[] {
24648                                    groupId, articleId, StringUtil.merge(statuses)
24649                            };
24650    
24651                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
24652                                    finderArgs, this);
24653    
24654                    if (count == null) {
24655                            StringBundler query = new StringBundler();
24656    
24657                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24658    
24659                            boolean conjunctionable = false;
24660    
24661                            if (conjunctionable) {
24662                                    query.append(WHERE_AND);
24663                            }
24664    
24665                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
24666    
24667                            conjunctionable = true;
24668    
24669                            if (conjunctionable) {
24670                                    query.append(WHERE_AND);
24671                            }
24672    
24673                            if (articleId == null) {
24674                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
24675                            }
24676                            else if (articleId.equals(StringPool.BLANK)) {
24677                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
24678                            }
24679                            else {
24680                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
24681                            }
24682    
24683                            conjunctionable = true;
24684    
24685                            if ((statuses == null) || (statuses.length > 0)) {
24686                                    if (conjunctionable) {
24687                                            query.append(WHERE_AND);
24688                                    }
24689    
24690                                    query.append(StringPool.OPEN_PARENTHESIS);
24691    
24692                                    for (int i = 0; i < statuses.length; i++) {
24693                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
24694    
24695                                            if ((i + 1) < statuses.length) {
24696                                                    query.append(WHERE_OR);
24697                                            }
24698                                    }
24699    
24700                                    query.append(StringPool.CLOSE_PARENTHESIS);
24701    
24702                                    conjunctionable = true;
24703                            }
24704    
24705                            String sql = query.toString();
24706    
24707                            Session session = null;
24708    
24709                            try {
24710                                    session = openSession();
24711    
24712                                    Query q = session.createQuery(sql);
24713    
24714                                    QueryPos qPos = QueryPos.getInstance(q);
24715    
24716                                    qPos.add(groupId);
24717    
24718                                    if (articleId != null) {
24719                                            qPos.add(articleId);
24720                                    }
24721    
24722                                    if (statuses != null) {
24723                                            qPos.add(statuses);
24724                                    }
24725    
24726                                    count = (Long)q.uniqueResult();
24727    
24728                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
24729                                            finderArgs, count);
24730                            }
24731                            catch (Exception e) {
24732                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
24733                                            finderArgs);
24734    
24735                                    throw processException(e);
24736                            }
24737                            finally {
24738                                    closeSession(session);
24739                            }
24740                    }
24741    
24742                    return count.intValue();
24743            }
24744    
24745            /**
24746             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
24747             *
24748             * @param groupId the group ID
24749             * @param articleId the article ID
24750             * @param status the status
24751             * @return the number of matching journal articles that the user has permission to view
24752             * @throws SystemException if a system exception occurred
24753             */
24754            @Override
24755            public int filterCountByG_A_ST(long groupId, String articleId, int status)
24756                    throws SystemException {
24757                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24758                            return countByG_A_ST(groupId, articleId, status);
24759                    }
24760    
24761                    StringBundler query = new StringBundler(4);
24762    
24763                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
24764    
24765                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24766    
24767                    boolean bindArticleId = false;
24768    
24769                    if (articleId == null) {
24770                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24771                    }
24772                    else if (articleId.equals(StringPool.BLANK)) {
24773                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24774                    }
24775                    else {
24776                            bindArticleId = true;
24777    
24778                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24779                    }
24780    
24781                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24782    
24783                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24784                                    JournalArticle.class.getName(),
24785                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24786    
24787                    Session session = null;
24788    
24789                    try {
24790                            session = openSession();
24791    
24792                            SQLQuery q = session.createSQLQuery(sql);
24793    
24794                            q.addScalar(COUNT_COLUMN_NAME,
24795                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24796    
24797                            QueryPos qPos = QueryPos.getInstance(q);
24798    
24799                            qPos.add(groupId);
24800    
24801                            if (bindArticleId) {
24802                                    qPos.add(articleId);
24803                            }
24804    
24805                            qPos.add(status);
24806    
24807                            Long count = (Long)q.uniqueResult();
24808    
24809                            return count.intValue();
24810                    }
24811                    catch (Exception e) {
24812                            throw processException(e);
24813                    }
24814                    finally {
24815                            closeSession(session);
24816                    }
24817            }
24818    
24819            /**
24820             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
24821             *
24822             * @param groupId the group ID
24823             * @param articleId the article ID
24824             * @param statuses the statuses
24825             * @return the number of matching journal articles that the user has permission to view
24826             * @throws SystemException if a system exception occurred
24827             */
24828            @Override
24829            public int filterCountByG_A_ST(long groupId, String articleId,
24830                    int[] statuses) throws SystemException {
24831                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24832                            return countByG_A_ST(groupId, articleId, statuses);
24833                    }
24834    
24835                    StringBundler query = new StringBundler();
24836    
24837                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
24838    
24839                    boolean conjunctionable = false;
24840    
24841                    if (conjunctionable) {
24842                            query.append(WHERE_AND);
24843                    }
24844    
24845                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
24846    
24847                    conjunctionable = true;
24848    
24849                    if (conjunctionable) {
24850                            query.append(WHERE_AND);
24851                    }
24852    
24853                    if (articleId == null) {
24854                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
24855                    }
24856                    else if (articleId.equals(StringPool.BLANK)) {
24857                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
24858                    }
24859                    else {
24860                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
24861                    }
24862    
24863                    conjunctionable = true;
24864    
24865                    if ((statuses == null) || (statuses.length > 0)) {
24866                            if (conjunctionable) {
24867                                    query.append(WHERE_AND);
24868                            }
24869    
24870                            query.append(StringPool.OPEN_PARENTHESIS);
24871    
24872                            for (int i = 0; i < statuses.length; i++) {
24873                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
24874    
24875                                    if ((i + 1) < statuses.length) {
24876                                            query.append(WHERE_OR);
24877                                    }
24878                            }
24879    
24880                            query.append(StringPool.CLOSE_PARENTHESIS);
24881    
24882                            conjunctionable = true;
24883                    }
24884    
24885                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24886                                    JournalArticle.class.getName(),
24887                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24888    
24889                    Session session = null;
24890    
24891                    try {
24892                            session = openSession();
24893    
24894                            SQLQuery q = session.createSQLQuery(sql);
24895    
24896                            q.addScalar(COUNT_COLUMN_NAME,
24897                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24898    
24899                            QueryPos qPos = QueryPos.getInstance(q);
24900    
24901                            qPos.add(groupId);
24902    
24903                            if (articleId != null) {
24904                                    qPos.add(articleId);
24905                            }
24906    
24907                            if (statuses != null) {
24908                                    qPos.add(statuses);
24909                            }
24910    
24911                            Long count = (Long)q.uniqueResult();
24912    
24913                            return count.intValue();
24914                    }
24915                    catch (Exception e) {
24916                            throw processException(e);
24917                    }
24918                    finally {
24919                            closeSession(session);
24920                    }
24921            }
24922    
24923            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
24924            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
24925                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
24926            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
24927            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
24928            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
24929            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
24930                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
24931            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
24932                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
24933            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
24934                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
24935            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
24936            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
24937                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
24938            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24939                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24940                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
24941                            "findByG_UT_ST",
24942                            new String[] {
24943                                    Long.class.getName(), String.class.getName(),
24944                                    Integer.class.getName(),
24945                                    
24946                            Integer.class.getName(), Integer.class.getName(),
24947                                    OrderByComparator.class.getName()
24948                            });
24949            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
24950                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24951                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24952                            JournalArticleImpl.class,
24953                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
24954                            new String[] {
24955                                    Long.class.getName(), String.class.getName(),
24956                                    Integer.class.getName()
24957                            },
24958                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24959                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
24960                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
24961                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24962                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24963            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24964                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24965                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
24966                            new String[] {
24967                                    Long.class.getName(), String.class.getName(),
24968                                    Integer.class.getName()
24969                            });
24970    
24971            /**
24972             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
24973             *
24974             * @param groupId the group ID
24975             * @param urlTitle the url title
24976             * @param status the status
24977             * @return the matching journal articles
24978             * @throws SystemException if a system exception occurred
24979             */
24980            @Override
24981            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
24982                    int status) throws SystemException {
24983                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
24984                            QueryUtil.ALL_POS, null);
24985            }
24986    
24987            /**
24988             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
24989             *
24990             * <p>
24991             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24992             * </p>
24993             *
24994             * @param groupId the group ID
24995             * @param urlTitle the url title
24996             * @param status the status
24997             * @param start the lower bound of the range of journal articles
24998             * @param end the upper bound of the range of journal articles (not inclusive)
24999             * @return the range of matching journal articles
25000             * @throws SystemException if a system exception occurred
25001             */
25002            @Override
25003            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
25004                    int status, int start, int end) throws SystemException {
25005                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
25006            }
25007    
25008            /**
25009             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25010             *
25011             * <p>
25012             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25013             * </p>
25014             *
25015             * @param groupId the group ID
25016             * @param urlTitle the url title
25017             * @param status the status
25018             * @param start the lower bound of the range of journal articles
25019             * @param end the upper bound of the range of journal articles (not inclusive)
25020             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25021             * @return the ordered range of matching journal articles
25022             * @throws SystemException if a system exception occurred
25023             */
25024            @Override
25025            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
25026                    int status, int start, int end, OrderByComparator orderByComparator)
25027                    throws SystemException {
25028                    boolean pagination = true;
25029                    FinderPath finderPath = null;
25030                    Object[] finderArgs = null;
25031    
25032                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25033                                    (orderByComparator == null)) {
25034                            pagination = false;
25035                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
25036                            finderArgs = new Object[] { groupId, urlTitle, status };
25037                    }
25038                    else {
25039                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
25040                            finderArgs = new Object[] {
25041                                            groupId, urlTitle, status,
25042                                            
25043                                            start, end, orderByComparator
25044                                    };
25045                    }
25046    
25047                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
25048                                    finderArgs, this);
25049    
25050                    if ((list != null) && !list.isEmpty()) {
25051                            for (JournalArticle journalArticle : list) {
25052                                    if ((groupId != journalArticle.getGroupId()) ||
25053                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
25054                                                    (status != journalArticle.getStatus())) {
25055                                            list = null;
25056    
25057                                            break;
25058                                    }
25059                            }
25060                    }
25061    
25062                    if (list == null) {
25063                            StringBundler query = null;
25064    
25065                            if (orderByComparator != null) {
25066                                    query = new StringBundler(5 +
25067                                                    (orderByComparator.getOrderByFields().length * 3));
25068                            }
25069                            else {
25070                                    query = new StringBundler(5);
25071                            }
25072    
25073                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25074    
25075                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25076    
25077                            boolean bindUrlTitle = false;
25078    
25079                            if (urlTitle == null) {
25080                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25081                            }
25082                            else if (urlTitle.equals(StringPool.BLANK)) {
25083                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25084                            }
25085                            else {
25086                                    bindUrlTitle = true;
25087    
25088                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25089                            }
25090    
25091                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25092    
25093                            if (orderByComparator != null) {
25094                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25095                                            orderByComparator);
25096                            }
25097                            else
25098                             if (pagination) {
25099                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25100                            }
25101    
25102                            String sql = query.toString();
25103    
25104                            Session session = null;
25105    
25106                            try {
25107                                    session = openSession();
25108    
25109                                    Query q = session.createQuery(sql);
25110    
25111                                    QueryPos qPos = QueryPos.getInstance(q);
25112    
25113                                    qPos.add(groupId);
25114    
25115                                    if (bindUrlTitle) {
25116                                            qPos.add(urlTitle);
25117                                    }
25118    
25119                                    qPos.add(status);
25120    
25121                                    if (!pagination) {
25122                                            list = (List<JournalArticle>)QueryUtil.list(q,
25123                                                            getDialect(), start, end, false);
25124    
25125                                            Collections.sort(list);
25126    
25127                                            list = new UnmodifiableList<JournalArticle>(list);
25128                                    }
25129                                    else {
25130                                            list = (List<JournalArticle>)QueryUtil.list(q,
25131                                                            getDialect(), start, end);
25132                                    }
25133    
25134                                    cacheResult(list);
25135    
25136                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
25137                            }
25138                            catch (Exception e) {
25139                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25140    
25141                                    throw processException(e);
25142                            }
25143                            finally {
25144                                    closeSession(session);
25145                            }
25146                    }
25147    
25148                    return list;
25149            }
25150    
25151            /**
25152             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25153             *
25154             * @param groupId the group ID
25155             * @param urlTitle the url title
25156             * @param status the status
25157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25158             * @return the first matching journal article
25159             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25160             * @throws SystemException if a system exception occurred
25161             */
25162            @Override
25163            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
25164                    int status, OrderByComparator orderByComparator)
25165                    throws NoSuchArticleException, SystemException {
25166                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
25167                                    status, orderByComparator);
25168    
25169                    if (journalArticle != null) {
25170                            return journalArticle;
25171                    }
25172    
25173                    StringBundler msg = new StringBundler(8);
25174    
25175                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25176    
25177                    msg.append("groupId=");
25178                    msg.append(groupId);
25179    
25180                    msg.append(", urlTitle=");
25181                    msg.append(urlTitle);
25182    
25183                    msg.append(", status=");
25184                    msg.append(status);
25185    
25186                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25187    
25188                    throw new NoSuchArticleException(msg.toString());
25189            }
25190    
25191            /**
25192             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25193             *
25194             * @param groupId the group ID
25195             * @param urlTitle the url title
25196             * @param status the status
25197             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25198             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
25199             * @throws SystemException if a system exception occurred
25200             */
25201            @Override
25202            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
25203                    int status, OrderByComparator orderByComparator)
25204                    throws SystemException {
25205                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
25206                                    1, orderByComparator);
25207    
25208                    if (!list.isEmpty()) {
25209                            return list.get(0);
25210                    }
25211    
25212                    return null;
25213            }
25214    
25215            /**
25216             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25217             *
25218             * @param groupId the group ID
25219             * @param urlTitle the url title
25220             * @param status the status
25221             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25222             * @return the last matching journal article
25223             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25224             * @throws SystemException if a system exception occurred
25225             */
25226            @Override
25227            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
25228                    int status, OrderByComparator orderByComparator)
25229                    throws NoSuchArticleException, SystemException {
25230                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
25231                                    status, orderByComparator);
25232    
25233                    if (journalArticle != null) {
25234                            return journalArticle;
25235                    }
25236    
25237                    StringBundler msg = new StringBundler(8);
25238    
25239                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25240    
25241                    msg.append("groupId=");
25242                    msg.append(groupId);
25243    
25244                    msg.append(", urlTitle=");
25245                    msg.append(urlTitle);
25246    
25247                    msg.append(", status=");
25248                    msg.append(status);
25249    
25250                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25251    
25252                    throw new NoSuchArticleException(msg.toString());
25253            }
25254    
25255            /**
25256             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25257             *
25258             * @param groupId the group ID
25259             * @param urlTitle the url title
25260             * @param status the status
25261             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25262             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
25263             * @throws SystemException if a system exception occurred
25264             */
25265            @Override
25266            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
25267                    int status, OrderByComparator orderByComparator)
25268                    throws SystemException {
25269                    int count = countByG_UT_ST(groupId, urlTitle, status);
25270    
25271                    if (count == 0) {
25272                            return null;
25273                    }
25274    
25275                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
25276                                    count - 1, count, orderByComparator);
25277    
25278                    if (!list.isEmpty()) {
25279                            return list.get(0);
25280                    }
25281    
25282                    return null;
25283            }
25284    
25285            /**
25286             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25287             *
25288             * @param id the primary key of the current journal article
25289             * @param groupId the group ID
25290             * @param urlTitle the url title
25291             * @param status the status
25292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25293             * @return the previous, current, and next journal article
25294             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25295             * @throws SystemException if a system exception occurred
25296             */
25297            @Override
25298            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
25299                    String urlTitle, int status, OrderByComparator orderByComparator)
25300                    throws NoSuchArticleException, SystemException {
25301                    JournalArticle journalArticle = findByPrimaryKey(id);
25302    
25303                    Session session = null;
25304    
25305                    try {
25306                            session = openSession();
25307    
25308                            JournalArticle[] array = new JournalArticleImpl[3];
25309    
25310                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
25311                                            groupId, urlTitle, status, orderByComparator, true);
25312    
25313                            array[1] = journalArticle;
25314    
25315                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
25316                                            groupId, urlTitle, status, orderByComparator, false);
25317    
25318                            return array;
25319                    }
25320                    catch (Exception e) {
25321                            throw processException(e);
25322                    }
25323                    finally {
25324                            closeSession(session);
25325                    }
25326            }
25327    
25328            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
25329                    JournalArticle journalArticle, long groupId, String urlTitle,
25330                    int status, OrderByComparator orderByComparator, boolean previous) {
25331                    StringBundler query = null;
25332    
25333                    if (orderByComparator != null) {
25334                            query = new StringBundler(6 +
25335                                            (orderByComparator.getOrderByFields().length * 6));
25336                    }
25337                    else {
25338                            query = new StringBundler(3);
25339                    }
25340    
25341                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25342    
25343                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25344    
25345                    boolean bindUrlTitle = false;
25346    
25347                    if (urlTitle == null) {
25348                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25349                    }
25350                    else if (urlTitle.equals(StringPool.BLANK)) {
25351                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25352                    }
25353                    else {
25354                            bindUrlTitle = true;
25355    
25356                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25357                    }
25358    
25359                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25360    
25361                    if (orderByComparator != null) {
25362                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25363    
25364                            if (orderByConditionFields.length > 0) {
25365                                    query.append(WHERE_AND);
25366                            }
25367    
25368                            for (int i = 0; i < orderByConditionFields.length; i++) {
25369                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25370                                    query.append(orderByConditionFields[i]);
25371    
25372                                    if ((i + 1) < orderByConditionFields.length) {
25373                                            if (orderByComparator.isAscending() ^ previous) {
25374                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25375                                            }
25376                                            else {
25377                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25378                                            }
25379                                    }
25380                                    else {
25381                                            if (orderByComparator.isAscending() ^ previous) {
25382                                                    query.append(WHERE_GREATER_THAN);
25383                                            }
25384                                            else {
25385                                                    query.append(WHERE_LESSER_THAN);
25386                                            }
25387                                    }
25388                            }
25389    
25390                            query.append(ORDER_BY_CLAUSE);
25391    
25392                            String[] orderByFields = orderByComparator.getOrderByFields();
25393    
25394                            for (int i = 0; i < orderByFields.length; i++) {
25395                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25396                                    query.append(orderByFields[i]);
25397    
25398                                    if ((i + 1) < orderByFields.length) {
25399                                            if (orderByComparator.isAscending() ^ previous) {
25400                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25401                                            }
25402                                            else {
25403                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25404                                            }
25405                                    }
25406                                    else {
25407                                            if (orderByComparator.isAscending() ^ previous) {
25408                                                    query.append(ORDER_BY_ASC);
25409                                            }
25410                                            else {
25411                                                    query.append(ORDER_BY_DESC);
25412                                            }
25413                                    }
25414                            }
25415                    }
25416                    else {
25417                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25418                    }
25419    
25420                    String sql = query.toString();
25421    
25422                    Query q = session.createQuery(sql);
25423    
25424                    q.setFirstResult(0);
25425                    q.setMaxResults(2);
25426    
25427                    QueryPos qPos = QueryPos.getInstance(q);
25428    
25429                    qPos.add(groupId);
25430    
25431                    if (bindUrlTitle) {
25432                            qPos.add(urlTitle);
25433                    }
25434    
25435                    qPos.add(status);
25436    
25437                    if (orderByComparator != null) {
25438                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25439    
25440                            for (Object value : values) {
25441                                    qPos.add(value);
25442                            }
25443                    }
25444    
25445                    List<JournalArticle> list = q.list();
25446    
25447                    if (list.size() == 2) {
25448                            return list.get(1);
25449                    }
25450                    else {
25451                            return null;
25452                    }
25453            }
25454    
25455            /**
25456             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25457             *
25458             * @param groupId the group ID
25459             * @param urlTitle the url title
25460             * @param status the status
25461             * @return the matching journal articles that the user has permission to view
25462             * @throws SystemException if a system exception occurred
25463             */
25464            @Override
25465            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
25466                    String urlTitle, int status) throws SystemException {
25467                    return filterFindByG_UT_ST(groupId, urlTitle, status,
25468                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25469            }
25470    
25471            /**
25472             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25473             *
25474             * <p>
25475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25476             * </p>
25477             *
25478             * @param groupId the group ID
25479             * @param urlTitle the url title
25480             * @param status the status
25481             * @param start the lower bound of the range of journal articles
25482             * @param end the upper bound of the range of journal articles (not inclusive)
25483             * @return the range of matching journal articles that the user has permission to view
25484             * @throws SystemException if a system exception occurred
25485             */
25486            @Override
25487            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
25488                    String urlTitle, int status, int start, int end)
25489                    throws SystemException {
25490                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
25491            }
25492    
25493            /**
25494             * 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;.
25495             *
25496             * <p>
25497             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25498             * </p>
25499             *
25500             * @param groupId the group ID
25501             * @param urlTitle the url title
25502             * @param status the status
25503             * @param start the lower bound of the range of journal articles
25504             * @param end the upper bound of the range of journal articles (not inclusive)
25505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25506             * @return the ordered range of matching journal articles that the user has permission to view
25507             * @throws SystemException if a system exception occurred
25508             */
25509            @Override
25510            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
25511                    String urlTitle, int status, int start, int end,
25512                    OrderByComparator orderByComparator) throws SystemException {
25513                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25514                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
25515                                    orderByComparator);
25516                    }
25517    
25518                    StringBundler query = null;
25519    
25520                    if (orderByComparator != null) {
25521                            query = new StringBundler(5 +
25522                                            (orderByComparator.getOrderByFields().length * 3));
25523                    }
25524                    else {
25525                            query = new StringBundler(5);
25526                    }
25527    
25528                    if (getDB().isSupportsInlineDistinct()) {
25529                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25530                    }
25531                    else {
25532                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25533                    }
25534    
25535                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25536    
25537                    boolean bindUrlTitle = false;
25538    
25539                    if (urlTitle == null) {
25540                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25541                    }
25542                    else if (urlTitle.equals(StringPool.BLANK)) {
25543                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25544                    }
25545                    else {
25546                            bindUrlTitle = true;
25547    
25548                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25549                    }
25550    
25551                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25552    
25553                    if (!getDB().isSupportsInlineDistinct()) {
25554                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25555                    }
25556    
25557                    if (orderByComparator != null) {
25558                            if (getDB().isSupportsInlineDistinct()) {
25559                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25560                                            orderByComparator, true);
25561                            }
25562                            else {
25563                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25564                                            orderByComparator, true);
25565                            }
25566                    }
25567                    else {
25568                            if (getDB().isSupportsInlineDistinct()) {
25569                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25570                            }
25571                            else {
25572                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25573                            }
25574                    }
25575    
25576                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25577                                    JournalArticle.class.getName(),
25578                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25579    
25580                    Session session = null;
25581    
25582                    try {
25583                            session = openSession();
25584    
25585                            SQLQuery q = session.createSQLQuery(sql);
25586    
25587                            if (getDB().isSupportsInlineDistinct()) {
25588                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25589                            }
25590                            else {
25591                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25592                            }
25593    
25594                            QueryPos qPos = QueryPos.getInstance(q);
25595    
25596                            qPos.add(groupId);
25597    
25598                            if (bindUrlTitle) {
25599                                    qPos.add(urlTitle);
25600                            }
25601    
25602                            qPos.add(status);
25603    
25604                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25605                                    end);
25606                    }
25607                    catch (Exception e) {
25608                            throw processException(e);
25609                    }
25610                    finally {
25611                            closeSession(session);
25612                    }
25613            }
25614    
25615            /**
25616             * 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;.
25617             *
25618             * @param id the primary key of the current journal article
25619             * @param groupId the group ID
25620             * @param urlTitle the url title
25621             * @param status the status
25622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25623             * @return the previous, current, and next journal article
25624             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25625             * @throws SystemException if a system exception occurred
25626             */
25627            @Override
25628            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
25629                    long groupId, String urlTitle, int status,
25630                    OrderByComparator orderByComparator)
25631                    throws NoSuchArticleException, SystemException {
25632                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25633                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
25634                                    orderByComparator);
25635                    }
25636    
25637                    JournalArticle journalArticle = findByPrimaryKey(id);
25638    
25639                    Session session = null;
25640    
25641                    try {
25642                            session = openSession();
25643    
25644                            JournalArticle[] array = new JournalArticleImpl[3];
25645    
25646                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
25647                                            groupId, urlTitle, status, orderByComparator, true);
25648    
25649                            array[1] = journalArticle;
25650    
25651                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
25652                                            groupId, urlTitle, status, orderByComparator, false);
25653    
25654                            return array;
25655                    }
25656                    catch (Exception e) {
25657                            throw processException(e);
25658                    }
25659                    finally {
25660                            closeSession(session);
25661                    }
25662            }
25663    
25664            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
25665                    JournalArticle journalArticle, long groupId, String urlTitle,
25666                    int status, OrderByComparator orderByComparator, boolean previous) {
25667                    StringBundler query = null;
25668    
25669                    if (orderByComparator != null) {
25670                            query = new StringBundler(6 +
25671                                            (orderByComparator.getOrderByFields().length * 6));
25672                    }
25673                    else {
25674                            query = new StringBundler(3);
25675                    }
25676    
25677                    if (getDB().isSupportsInlineDistinct()) {
25678                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25679                    }
25680                    else {
25681                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25682                    }
25683    
25684                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25685    
25686                    boolean bindUrlTitle = false;
25687    
25688                    if (urlTitle == null) {
25689                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25690                    }
25691                    else if (urlTitle.equals(StringPool.BLANK)) {
25692                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25693                    }
25694                    else {
25695                            bindUrlTitle = true;
25696    
25697                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25698                    }
25699    
25700                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25701    
25702                    if (!getDB().isSupportsInlineDistinct()) {
25703                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25704                    }
25705    
25706                    if (orderByComparator != null) {
25707                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25708    
25709                            if (orderByConditionFields.length > 0) {
25710                                    query.append(WHERE_AND);
25711                            }
25712    
25713                            for (int i = 0; i < orderByConditionFields.length; i++) {
25714                                    if (getDB().isSupportsInlineDistinct()) {
25715                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25716                                    }
25717                                    else {
25718                                            query.append(_ORDER_BY_ENTITY_TABLE);
25719                                    }
25720    
25721                                    query.append(orderByConditionFields[i]);
25722    
25723                                    if ((i + 1) < orderByConditionFields.length) {
25724                                            if (orderByComparator.isAscending() ^ previous) {
25725                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25726                                            }
25727                                            else {
25728                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25729                                            }
25730                                    }
25731                                    else {
25732                                            if (orderByComparator.isAscending() ^ previous) {
25733                                                    query.append(WHERE_GREATER_THAN);
25734                                            }
25735                                            else {
25736                                                    query.append(WHERE_LESSER_THAN);
25737                                            }
25738                                    }
25739                            }
25740    
25741                            query.append(ORDER_BY_CLAUSE);
25742    
25743                            String[] orderByFields = orderByComparator.getOrderByFields();
25744    
25745                            for (int i = 0; i < orderByFields.length; i++) {
25746                                    if (getDB().isSupportsInlineDistinct()) {
25747                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25748                                    }
25749                                    else {
25750                                            query.append(_ORDER_BY_ENTITY_TABLE);
25751                                    }
25752    
25753                                    query.append(orderByFields[i]);
25754    
25755                                    if ((i + 1) < orderByFields.length) {
25756                                            if (orderByComparator.isAscending() ^ previous) {
25757                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25758                                            }
25759                                            else {
25760                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25761                                            }
25762                                    }
25763                                    else {
25764                                            if (orderByComparator.isAscending() ^ previous) {
25765                                                    query.append(ORDER_BY_ASC);
25766                                            }
25767                                            else {
25768                                                    query.append(ORDER_BY_DESC);
25769                                            }
25770                                    }
25771                            }
25772                    }
25773                    else {
25774                            if (getDB().isSupportsInlineDistinct()) {
25775                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25776                            }
25777                            else {
25778                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25779                            }
25780                    }
25781    
25782                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25783                                    JournalArticle.class.getName(),
25784                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25785    
25786                    SQLQuery q = session.createSQLQuery(sql);
25787    
25788                    q.setFirstResult(0);
25789                    q.setMaxResults(2);
25790    
25791                    if (getDB().isSupportsInlineDistinct()) {
25792                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25793                    }
25794                    else {
25795                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25796                    }
25797    
25798                    QueryPos qPos = QueryPos.getInstance(q);
25799    
25800                    qPos.add(groupId);
25801    
25802                    if (bindUrlTitle) {
25803                            qPos.add(urlTitle);
25804                    }
25805    
25806                    qPos.add(status);
25807    
25808                    if (orderByComparator != null) {
25809                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25810    
25811                            for (Object value : values) {
25812                                    qPos.add(value);
25813                            }
25814                    }
25815    
25816                    List<JournalArticle> list = q.list();
25817    
25818                    if (list.size() == 2) {
25819                            return list.get(1);
25820                    }
25821                    else {
25822                            return null;
25823                    }
25824            }
25825    
25826            /**
25827             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
25828             *
25829             * @param groupId the group ID
25830             * @param urlTitle the url title
25831             * @param status the status
25832             * @throws SystemException if a system exception occurred
25833             */
25834            @Override
25835            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
25836                    throws SystemException {
25837                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
25838                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
25839                            remove(journalArticle);
25840                    }
25841            }
25842    
25843            /**
25844             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25845             *
25846             * @param groupId the group ID
25847             * @param urlTitle the url title
25848             * @param status the status
25849             * @return the number of matching journal articles
25850             * @throws SystemException if a system exception occurred
25851             */
25852            @Override
25853            public int countByG_UT_ST(long groupId, String urlTitle, int status)
25854                    throws SystemException {
25855                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
25856    
25857                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
25858    
25859                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25860                                    this);
25861    
25862                    if (count == null) {
25863                            StringBundler query = new StringBundler(4);
25864    
25865                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25866    
25867                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25868    
25869                            boolean bindUrlTitle = false;
25870    
25871                            if (urlTitle == null) {
25872                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25873                            }
25874                            else if (urlTitle.equals(StringPool.BLANK)) {
25875                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25876                            }
25877                            else {
25878                                    bindUrlTitle = true;
25879    
25880                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25881                            }
25882    
25883                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25884    
25885                            String sql = query.toString();
25886    
25887                            Session session = null;
25888    
25889                            try {
25890                                    session = openSession();
25891    
25892                                    Query q = session.createQuery(sql);
25893    
25894                                    QueryPos qPos = QueryPos.getInstance(q);
25895    
25896                                    qPos.add(groupId);
25897    
25898                                    if (bindUrlTitle) {
25899                                            qPos.add(urlTitle);
25900                                    }
25901    
25902                                    qPos.add(status);
25903    
25904                                    count = (Long)q.uniqueResult();
25905    
25906                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25907                            }
25908                            catch (Exception e) {
25909                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25910    
25911                                    throw processException(e);
25912                            }
25913                            finally {
25914                                    closeSession(session);
25915                            }
25916                    }
25917    
25918                    return count.intValue();
25919            }
25920    
25921            /**
25922             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
25923             *
25924             * @param groupId the group ID
25925             * @param urlTitle the url title
25926             * @param status the status
25927             * @return the number of matching journal articles that the user has permission to view
25928             * @throws SystemException if a system exception occurred
25929             */
25930            @Override
25931            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
25932                    throws SystemException {
25933                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25934                            return countByG_UT_ST(groupId, urlTitle, status);
25935                    }
25936    
25937                    StringBundler query = new StringBundler(4);
25938    
25939                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25940    
25941                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
25942    
25943                    boolean bindUrlTitle = false;
25944    
25945                    if (urlTitle == null) {
25946                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
25947                    }
25948                    else if (urlTitle.equals(StringPool.BLANK)) {
25949                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
25950                    }
25951                    else {
25952                            bindUrlTitle = true;
25953    
25954                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
25955                    }
25956    
25957                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
25958    
25959                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25960                                    JournalArticle.class.getName(),
25961                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25962    
25963                    Session session = null;
25964    
25965                    try {
25966                            session = openSession();
25967    
25968                            SQLQuery q = session.createSQLQuery(sql);
25969    
25970                            q.addScalar(COUNT_COLUMN_NAME,
25971                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
25972    
25973                            QueryPos qPos = QueryPos.getInstance(q);
25974    
25975                            qPos.add(groupId);
25976    
25977                            if (bindUrlTitle) {
25978                                    qPos.add(urlTitle);
25979                            }
25980    
25981                            qPos.add(status);
25982    
25983                            Long count = (Long)q.uniqueResult();
25984    
25985                            return count.intValue();
25986                    }
25987                    catch (Exception e) {
25988                            throw processException(e);
25989                    }
25990                    finally {
25991                            closeSession(session);
25992                    }
25993            }
25994    
25995            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
25996            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
25997            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
25998            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
25999            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
26000            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26001                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26002                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
26003                            "findByC_V_ST",
26004                            new String[] {
26005                                    Long.class.getName(), Double.class.getName(),
26006                                    Integer.class.getName(),
26007                                    
26008                            Integer.class.getName(), Integer.class.getName(),
26009                                    OrderByComparator.class.getName()
26010                            });
26011            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
26012                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26013                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26014                            JournalArticleImpl.class,
26015                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
26016                            new String[] {
26017                                    Long.class.getName(), Double.class.getName(),
26018                                    Integer.class.getName()
26019                            },
26020                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
26021                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
26022                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
26023                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
26024            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26025                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26026                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
26027                            new String[] {
26028                                    Long.class.getName(), Double.class.getName(),
26029                                    Integer.class.getName()
26030                            });
26031    
26032            /**
26033             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
26034             *
26035             * @param companyId the company ID
26036             * @param version the version
26037             * @param status the status
26038             * @return the matching journal articles
26039             * @throws SystemException if a system exception occurred
26040             */
26041            @Override
26042            public List<JournalArticle> findByC_V_ST(long companyId, double version,
26043                    int status) throws SystemException {
26044                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
26045                            QueryUtil.ALL_POS, null);
26046            }
26047    
26048            /**
26049             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
26050             *
26051             * <p>
26052             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26053             * </p>
26054             *
26055             * @param companyId the company ID
26056             * @param version the version
26057             * @param status the status
26058             * @param start the lower bound of the range of journal articles
26059             * @param end the upper bound of the range of journal articles (not inclusive)
26060             * @return the range of matching journal articles
26061             * @throws SystemException if a system exception occurred
26062             */
26063            @Override
26064            public List<JournalArticle> findByC_V_ST(long companyId, double version,
26065                    int status, int start, int end) throws SystemException {
26066                    return findByC_V_ST(companyId, version, status, start, end, null);
26067            }
26068    
26069            /**
26070             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
26071             *
26072             * <p>
26073             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26074             * </p>
26075             *
26076             * @param companyId the company ID
26077             * @param version the version
26078             * @param status the status
26079             * @param start the lower bound of the range of journal articles
26080             * @param end the upper bound of the range of journal articles (not inclusive)
26081             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26082             * @return the ordered range of matching journal articles
26083             * @throws SystemException if a system exception occurred
26084             */
26085            @Override
26086            public List<JournalArticle> findByC_V_ST(long companyId, double version,
26087                    int status, int start, int end, OrderByComparator orderByComparator)
26088                    throws SystemException {
26089                    boolean pagination = true;
26090                    FinderPath finderPath = null;
26091                    Object[] finderArgs = null;
26092    
26093                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
26094                                    (orderByComparator == null)) {
26095                            pagination = false;
26096                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
26097                            finderArgs = new Object[] { companyId, version, status };
26098                    }
26099                    else {
26100                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
26101                            finderArgs = new Object[] {
26102                                            companyId, version, status,
26103                                            
26104                                            start, end, orderByComparator
26105                                    };
26106                    }
26107    
26108                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26109                                    finderArgs, this);
26110    
26111                    if ((list != null) && !list.isEmpty()) {
26112                            for (JournalArticle journalArticle : list) {
26113                                    if ((companyId != journalArticle.getCompanyId()) ||
26114                                                    (version != journalArticle.getVersion()) ||
26115                                                    (status != journalArticle.getStatus())) {
26116                                            list = null;
26117    
26118                                            break;
26119                                    }
26120                            }
26121                    }
26122    
26123                    if (list == null) {
26124                            StringBundler query = null;
26125    
26126                            if (orderByComparator != null) {
26127                                    query = new StringBundler(5 +
26128                                                    (orderByComparator.getOrderByFields().length * 3));
26129                            }
26130                            else {
26131                                    query = new StringBundler(5);
26132                            }
26133    
26134                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26135    
26136                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
26137    
26138                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
26139    
26140                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
26141    
26142                            if (orderByComparator != null) {
26143                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26144                                            orderByComparator);
26145                            }
26146                            else
26147                             if (pagination) {
26148                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26149                            }
26150    
26151                            String sql = query.toString();
26152    
26153                            Session session = null;
26154    
26155                            try {
26156                                    session = openSession();
26157    
26158                                    Query q = session.createQuery(sql);
26159    
26160                                    QueryPos qPos = QueryPos.getInstance(q);
26161    
26162                                    qPos.add(companyId);
26163    
26164                                    qPos.add(version);
26165    
26166                                    qPos.add(status);
26167    
26168                                    if (!pagination) {
26169                                            list = (List<JournalArticle>)QueryUtil.list(q,
26170                                                            getDialect(), start, end, false);
26171    
26172                                            Collections.sort(list);
26173    
26174                                            list = new UnmodifiableList<JournalArticle>(list);
26175                                    }
26176                                    else {
26177                                            list = (List<JournalArticle>)QueryUtil.list(q,
26178                                                            getDialect(), start, end);
26179                                    }
26180    
26181                                    cacheResult(list);
26182    
26183                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
26184                            }
26185                            catch (Exception e) {
26186                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26187    
26188                                    throw processException(e);
26189                            }
26190                            finally {
26191                                    closeSession(session);
26192                            }
26193                    }
26194    
26195                    return list;
26196            }
26197    
26198            /**
26199             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26200             *
26201             * @param companyId the company ID
26202             * @param version the version
26203             * @param status the status
26204             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26205             * @return the first matching journal article
26206             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26207             * @throws SystemException if a system exception occurred
26208             */
26209            @Override
26210            public JournalArticle findByC_V_ST_First(long companyId, double version,
26211                    int status, OrderByComparator orderByComparator)
26212                    throws NoSuchArticleException, SystemException {
26213                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
26214                                    status, orderByComparator);
26215    
26216                    if (journalArticle != null) {
26217                            return journalArticle;
26218                    }
26219    
26220                    StringBundler msg = new StringBundler(8);
26221    
26222                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26223    
26224                    msg.append("companyId=");
26225                    msg.append(companyId);
26226    
26227                    msg.append(", version=");
26228                    msg.append(version);
26229    
26230                    msg.append(", status=");
26231                    msg.append(status);
26232    
26233                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26234    
26235                    throw new NoSuchArticleException(msg.toString());
26236            }
26237    
26238            /**
26239             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26240             *
26241             * @param companyId the company ID
26242             * @param version the version
26243             * @param status the status
26244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26245             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
26246             * @throws SystemException if a system exception occurred
26247             */
26248            @Override
26249            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
26250                    int status, OrderByComparator orderByComparator)
26251                    throws SystemException {
26252                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
26253                                    1, orderByComparator);
26254    
26255                    if (!list.isEmpty()) {
26256                            return list.get(0);
26257                    }
26258    
26259                    return null;
26260            }
26261    
26262            /**
26263             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26264             *
26265             * @param companyId the company ID
26266             * @param version the version
26267             * @param status the status
26268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26269             * @return the last matching journal article
26270             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26271             * @throws SystemException if a system exception occurred
26272             */
26273            @Override
26274            public JournalArticle findByC_V_ST_Last(long companyId, double version,
26275                    int status, OrderByComparator orderByComparator)
26276                    throws NoSuchArticleException, SystemException {
26277                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
26278                                    status, orderByComparator);
26279    
26280                    if (journalArticle != null) {
26281                            return journalArticle;
26282                    }
26283    
26284                    StringBundler msg = new StringBundler(8);
26285    
26286                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26287    
26288                    msg.append("companyId=");
26289                    msg.append(companyId);
26290    
26291                    msg.append(", version=");
26292                    msg.append(version);
26293    
26294                    msg.append(", status=");
26295                    msg.append(status);
26296    
26297                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26298    
26299                    throw new NoSuchArticleException(msg.toString());
26300            }
26301    
26302            /**
26303             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26304             *
26305             * @param companyId the company ID
26306             * @param version the version
26307             * @param status the status
26308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26309             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
26310             * @throws SystemException if a system exception occurred
26311             */
26312            @Override
26313            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
26314                    int status, OrderByComparator orderByComparator)
26315                    throws SystemException {
26316                    int count = countByC_V_ST(companyId, version, status);
26317    
26318                    if (count == 0) {
26319                            return null;
26320                    }
26321    
26322                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
26323                                    count - 1, count, orderByComparator);
26324    
26325                    if (!list.isEmpty()) {
26326                            return list.get(0);
26327                    }
26328    
26329                    return null;
26330            }
26331    
26332            /**
26333             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
26334             *
26335             * @param id the primary key of the current journal article
26336             * @param companyId the company ID
26337             * @param version the version
26338             * @param status the status
26339             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26340             * @return the previous, current, and next journal article
26341             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26342             * @throws SystemException if a system exception occurred
26343             */
26344            @Override
26345            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
26346                    double version, int status, OrderByComparator orderByComparator)
26347                    throws NoSuchArticleException, SystemException {
26348                    JournalArticle journalArticle = findByPrimaryKey(id);
26349    
26350                    Session session = null;
26351    
26352                    try {
26353                            session = openSession();
26354    
26355                            JournalArticle[] array = new JournalArticleImpl[3];
26356    
26357                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
26358                                            companyId, version, status, orderByComparator, true);
26359    
26360                            array[1] = journalArticle;
26361    
26362                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
26363                                            companyId, version, status, orderByComparator, false);
26364    
26365                            return array;
26366                    }
26367                    catch (Exception e) {
26368                            throw processException(e);
26369                    }
26370                    finally {
26371                            closeSession(session);
26372                    }
26373            }
26374    
26375            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
26376                    JournalArticle journalArticle, long companyId, double version,
26377                    int status, OrderByComparator orderByComparator, boolean previous) {
26378                    StringBundler query = null;
26379    
26380                    if (orderByComparator != null) {
26381                            query = new StringBundler(6 +
26382                                            (orderByComparator.getOrderByFields().length * 6));
26383                    }
26384                    else {
26385                            query = new StringBundler(3);
26386                    }
26387    
26388                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26389    
26390                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
26391    
26392                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
26393    
26394                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
26395    
26396                    if (orderByComparator != null) {
26397                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26398    
26399                            if (orderByConditionFields.length > 0) {
26400                                    query.append(WHERE_AND);
26401                            }
26402    
26403                            for (int i = 0; i < orderByConditionFields.length; i++) {
26404                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26405                                    query.append(orderByConditionFields[i]);
26406    
26407                                    if ((i + 1) < orderByConditionFields.length) {
26408                                            if (orderByComparator.isAscending() ^ previous) {
26409                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26410                                            }
26411                                            else {
26412                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26413                                            }
26414                                    }
26415                                    else {
26416                                            if (orderByComparator.isAscending() ^ previous) {
26417                                                    query.append(WHERE_GREATER_THAN);
26418                                            }
26419                                            else {
26420                                                    query.append(WHERE_LESSER_THAN);
26421                                            }
26422                                    }
26423                            }
26424    
26425                            query.append(ORDER_BY_CLAUSE);
26426    
26427                            String[] orderByFields = orderByComparator.getOrderByFields();
26428    
26429                            for (int i = 0; i < orderByFields.length; i++) {
26430                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26431                                    query.append(orderByFields[i]);
26432    
26433                                    if ((i + 1) < orderByFields.length) {
26434                                            if (orderByComparator.isAscending() ^ previous) {
26435                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26436                                            }
26437                                            else {
26438                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26439                                            }
26440                                    }
26441                                    else {
26442                                            if (orderByComparator.isAscending() ^ previous) {
26443                                                    query.append(ORDER_BY_ASC);
26444                                            }
26445                                            else {
26446                                                    query.append(ORDER_BY_DESC);
26447                                            }
26448                                    }
26449                            }
26450                    }
26451                    else {
26452                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26453                    }
26454    
26455                    String sql = query.toString();
26456    
26457                    Query q = session.createQuery(sql);
26458    
26459                    q.setFirstResult(0);
26460                    q.setMaxResults(2);
26461    
26462                    QueryPos qPos = QueryPos.getInstance(q);
26463    
26464                    qPos.add(companyId);
26465    
26466                    qPos.add(version);
26467    
26468                    qPos.add(status);
26469    
26470                    if (orderByComparator != null) {
26471                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26472    
26473                            for (Object value : values) {
26474                                    qPos.add(value);
26475                            }
26476                    }
26477    
26478                    List<JournalArticle> list = q.list();
26479    
26480                    if (list.size() == 2) {
26481                            return list.get(1);
26482                    }
26483                    else {
26484                            return null;
26485                    }
26486            }
26487    
26488            /**
26489             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
26490             *
26491             * @param companyId the company ID
26492             * @param version the version
26493             * @param status the status
26494             * @throws SystemException if a system exception occurred
26495             */
26496            @Override
26497            public void removeByC_V_ST(long companyId, double version, int status)
26498                    throws SystemException {
26499                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
26500                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26501                            remove(journalArticle);
26502                    }
26503            }
26504    
26505            /**
26506             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
26507             *
26508             * @param companyId the company ID
26509             * @param version the version
26510             * @param status the status
26511             * @return the number of matching journal articles
26512             * @throws SystemException if a system exception occurred
26513             */
26514            @Override
26515            public int countByC_V_ST(long companyId, double version, int status)
26516                    throws SystemException {
26517                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
26518    
26519                    Object[] finderArgs = new Object[] { companyId, version, status };
26520    
26521                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26522                                    this);
26523    
26524                    if (count == null) {
26525                            StringBundler query = new StringBundler(4);
26526    
26527                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26528    
26529                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
26530    
26531                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
26532    
26533                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
26534    
26535                            String sql = query.toString();
26536    
26537                            Session session = null;
26538    
26539                            try {
26540                                    session = openSession();
26541    
26542                                    Query q = session.createQuery(sql);
26543    
26544                                    QueryPos qPos = QueryPos.getInstance(q);
26545    
26546                                    qPos.add(companyId);
26547    
26548                                    qPos.add(version);
26549    
26550                                    qPos.add(status);
26551    
26552                                    count = (Long)q.uniqueResult();
26553    
26554                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26555                            }
26556                            catch (Exception e) {
26557                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26558    
26559                                    throw processException(e);
26560                            }
26561                            finally {
26562                                    closeSession(session);
26563                            }
26564                    }
26565    
26566                    return count.intValue();
26567            }
26568    
26569            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
26570            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
26571            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
26572    
26573            public JournalArticlePersistenceImpl() {
26574                    setModelClass(JournalArticle.class);
26575            }
26576    
26577            /**
26578             * Caches the journal article in the entity cache if it is enabled.
26579             *
26580             * @param journalArticle the journal article
26581             */
26582            @Override
26583            public void cacheResult(JournalArticle journalArticle) {
26584                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26585                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
26586                            journalArticle);
26587    
26588                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
26589                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
26590                            journalArticle);
26591    
26592                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
26593                            new Object[] {
26594                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
26595                                    journalArticle.getStructureId()
26596                            }, journalArticle);
26597    
26598                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
26599                            new Object[] {
26600                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
26601                                    journalArticle.getVersion()
26602                            }, journalArticle);
26603    
26604                    journalArticle.resetOriginalValues();
26605            }
26606    
26607            /**
26608             * Caches the journal articles in the entity cache if it is enabled.
26609             *
26610             * @param journalArticles the journal articles
26611             */
26612            @Override
26613            public void cacheResult(List<JournalArticle> journalArticles) {
26614                    for (JournalArticle journalArticle : journalArticles) {
26615                            if (EntityCacheUtil.getResult(
26616                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26617                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
26618                                    cacheResult(journalArticle);
26619                            }
26620                            else {
26621                                    journalArticle.resetOriginalValues();
26622                            }
26623                    }
26624            }
26625    
26626            /**
26627             * Clears the cache for all journal articles.
26628             *
26629             * <p>
26630             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
26631             * </p>
26632             */
26633            @Override
26634            public void clearCache() {
26635                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
26636                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
26637                    }
26638    
26639                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
26640    
26641                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
26642                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
26643                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
26644            }
26645    
26646            /**
26647             * Clears the cache for the journal article.
26648             *
26649             * <p>
26650             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
26651             * </p>
26652             */
26653            @Override
26654            public void clearCache(JournalArticle journalArticle) {
26655                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26656                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
26657    
26658                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
26659                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
26660    
26661                    clearUniqueFindersCache(journalArticle);
26662            }
26663    
26664            @Override
26665            public void clearCache(List<JournalArticle> journalArticles) {
26666                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
26667                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
26668    
26669                    for (JournalArticle journalArticle : journalArticles) {
26670                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26671                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
26672    
26673                            clearUniqueFindersCache(journalArticle);
26674                    }
26675            }
26676    
26677            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
26678                    if (journalArticle.isNew()) {
26679                            Object[] args = new Object[] {
26680                                            journalArticle.getUuid(), journalArticle.getGroupId()
26681                                    };
26682    
26683                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
26684                                    Long.valueOf(1));
26685                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
26686                                    journalArticle);
26687    
26688                            args = new Object[] {
26689                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
26690                                            journalArticle.getStructureId()
26691                                    };
26692    
26693                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
26694                                    Long.valueOf(1));
26695                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
26696                                    journalArticle);
26697    
26698                            args = new Object[] {
26699                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
26700                                            journalArticle.getVersion()
26701                                    };
26702    
26703                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
26704                                    Long.valueOf(1));
26705                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
26706                                    journalArticle);
26707                    }
26708                    else {
26709                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
26710    
26711                            if ((journalArticleModelImpl.getColumnBitmask() &
26712                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
26713                                    Object[] args = new Object[] {
26714                                                    journalArticle.getUuid(), journalArticle.getGroupId()
26715                                            };
26716    
26717                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
26718                                            Long.valueOf(1));
26719                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
26720                                            journalArticle);
26721                            }
26722    
26723                            if ((journalArticleModelImpl.getColumnBitmask() &
26724                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
26725                                    Object[] args = new Object[] {
26726                                                    journalArticle.getGroupId(),
26727                                                    journalArticle.getClassNameId(),
26728                                                    journalArticle.getStructureId()
26729                                            };
26730    
26731                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
26732                                            Long.valueOf(1));
26733                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
26734                                            journalArticle);
26735                            }
26736    
26737                            if ((journalArticleModelImpl.getColumnBitmask() &
26738                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
26739                                    Object[] args = new Object[] {
26740                                                    journalArticle.getGroupId(),
26741                                                    journalArticle.getArticleId(),
26742                                                    journalArticle.getVersion()
26743                                            };
26744    
26745                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
26746                                            Long.valueOf(1));
26747                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
26748                                            journalArticle);
26749                            }
26750                    }
26751            }
26752    
26753            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
26754                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
26755    
26756                    Object[] args = new Object[] {
26757                                    journalArticle.getUuid(), journalArticle.getGroupId()
26758                            };
26759    
26760                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
26761                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
26762    
26763                    if ((journalArticleModelImpl.getColumnBitmask() &
26764                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
26765                            args = new Object[] {
26766                                            journalArticleModelImpl.getOriginalUuid(),
26767                                            journalArticleModelImpl.getOriginalGroupId()
26768                                    };
26769    
26770                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
26771                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
26772                    }
26773    
26774                    args = new Object[] {
26775                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
26776                                    journalArticle.getStructureId()
26777                            };
26778    
26779                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
26780                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
26781    
26782                    if ((journalArticleModelImpl.getColumnBitmask() &
26783                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
26784                            args = new Object[] {
26785                                            journalArticleModelImpl.getOriginalGroupId(),
26786                                            journalArticleModelImpl.getOriginalClassNameId(),
26787                                            journalArticleModelImpl.getOriginalStructureId()
26788                                    };
26789    
26790                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
26791                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
26792                    }
26793    
26794                    args = new Object[] {
26795                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
26796                                    journalArticle.getVersion()
26797                            };
26798    
26799                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
26800                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
26801    
26802                    if ((journalArticleModelImpl.getColumnBitmask() &
26803                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
26804                            args = new Object[] {
26805                                            journalArticleModelImpl.getOriginalGroupId(),
26806                                            journalArticleModelImpl.getOriginalArticleId(),
26807                                            journalArticleModelImpl.getOriginalVersion()
26808                                    };
26809    
26810                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
26811                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
26812                    }
26813            }
26814    
26815            /**
26816             * Creates a new journal article with the primary key. Does not add the journal article to the database.
26817             *
26818             * @param id the primary key for the new journal article
26819             * @return the new journal article
26820             */
26821            @Override
26822            public JournalArticle create(long id) {
26823                    JournalArticle journalArticle = new JournalArticleImpl();
26824    
26825                    journalArticle.setNew(true);
26826                    journalArticle.setPrimaryKey(id);
26827    
26828                    String uuid = PortalUUIDUtil.generate();
26829    
26830                    journalArticle.setUuid(uuid);
26831    
26832                    return journalArticle;
26833            }
26834    
26835            /**
26836             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
26837             *
26838             * @param id the primary key of the journal article
26839             * @return the journal article that was removed
26840             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26841             * @throws SystemException if a system exception occurred
26842             */
26843            @Override
26844            public JournalArticle remove(long id)
26845                    throws NoSuchArticleException, SystemException {
26846                    return remove((Serializable)id);
26847            }
26848    
26849            /**
26850             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
26851             *
26852             * @param primaryKey the primary key of the journal article
26853             * @return the journal article that was removed
26854             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26855             * @throws SystemException if a system exception occurred
26856             */
26857            @Override
26858            public JournalArticle remove(Serializable primaryKey)
26859                    throws NoSuchArticleException, SystemException {
26860                    Session session = null;
26861    
26862                    try {
26863                            session = openSession();
26864    
26865                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
26866                                            primaryKey);
26867    
26868                            if (journalArticle == null) {
26869                                    if (_log.isWarnEnabled()) {
26870                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
26871                                    }
26872    
26873                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
26874                                            primaryKey);
26875                            }
26876    
26877                            return remove(journalArticle);
26878                    }
26879                    catch (NoSuchArticleException nsee) {
26880                            throw nsee;
26881                    }
26882                    catch (Exception e) {
26883                            throw processException(e);
26884                    }
26885                    finally {
26886                            closeSession(session);
26887                    }
26888            }
26889    
26890            @Override
26891            protected JournalArticle removeImpl(JournalArticle journalArticle)
26892                    throws SystemException {
26893                    journalArticle = toUnwrappedModel(journalArticle);
26894    
26895                    Session session = null;
26896    
26897                    try {
26898                            session = openSession();
26899    
26900                            if (!session.contains(journalArticle)) {
26901                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
26902                                                    journalArticle.getPrimaryKeyObj());
26903                            }
26904    
26905                            if (journalArticle != null) {
26906                                    session.delete(journalArticle);
26907                            }
26908                    }
26909                    catch (Exception e) {
26910                            throw processException(e);
26911                    }
26912                    finally {
26913                            closeSession(session);
26914                    }
26915    
26916                    if (journalArticle != null) {
26917                            clearCache(journalArticle);
26918                    }
26919    
26920                    return journalArticle;
26921            }
26922    
26923            @Override
26924            public JournalArticle updateImpl(
26925                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
26926                    throws SystemException {
26927                    journalArticle = toUnwrappedModel(journalArticle);
26928    
26929                    boolean isNew = journalArticle.isNew();
26930    
26931                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
26932    
26933                    if (Validator.isNull(journalArticle.getUuid())) {
26934                            String uuid = PortalUUIDUtil.generate();
26935    
26936                            journalArticle.setUuid(uuid);
26937                    }
26938    
26939                    Session session = null;
26940    
26941                    try {
26942                            session = openSession();
26943    
26944                            if (journalArticle.isNew()) {
26945                                    session.save(journalArticle);
26946    
26947                                    journalArticle.setNew(false);
26948                            }
26949                            else {
26950                                    session.merge(journalArticle);
26951                            }
26952                    }
26953                    catch (Exception e) {
26954                            throw processException(e);
26955                    }
26956                    finally {
26957                            closeSession(session);
26958                    }
26959    
26960                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
26961    
26962                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
26963                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
26964                    }
26965    
26966                    else {
26967                            if ((journalArticleModelImpl.getColumnBitmask() &
26968                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
26969                                    Object[] args = new Object[] {
26970                                                    journalArticleModelImpl.getOriginalUuid()
26971                                            };
26972    
26973                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
26974                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
26975                                            args);
26976    
26977                                    args = new Object[] { journalArticleModelImpl.getUuid() };
26978    
26979                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
26980                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
26981                                            args);
26982                            }
26983    
26984                            if ((journalArticleModelImpl.getColumnBitmask() &
26985                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
26986                                    Object[] args = new Object[] {
26987                                                    journalArticleModelImpl.getOriginalUuid(),
26988                                                    journalArticleModelImpl.getOriginalCompanyId()
26989                                            };
26990    
26991                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
26992                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
26993                                            args);
26994    
26995                                    args = new Object[] {
26996                                                    journalArticleModelImpl.getUuid(),
26997                                                    journalArticleModelImpl.getCompanyId()
26998                                            };
26999    
27000                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
27001                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
27002                                            args);
27003                            }
27004    
27005                            if ((journalArticleModelImpl.getColumnBitmask() &
27006                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
27007                                    Object[] args = new Object[] {
27008                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
27009                                            };
27010    
27011                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
27012                                            args);
27013                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
27014                                            args);
27015    
27016                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
27017    
27018                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
27019                                            args);
27020                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
27021                                            args);
27022                            }
27023    
27024                            if ((journalArticleModelImpl.getColumnBitmask() &
27025                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
27026                                    Object[] args = new Object[] {
27027                                                    journalArticleModelImpl.getOriginalGroupId()
27028                                            };
27029    
27030                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
27031                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
27032                                            args);
27033    
27034                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
27035    
27036                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
27037                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
27038                                            args);
27039                            }
27040    
27041                            if ((journalArticleModelImpl.getColumnBitmask() &
27042                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
27043                                    Object[] args = new Object[] {
27044                                                    journalArticleModelImpl.getOriginalCompanyId()
27045                                            };
27046    
27047                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
27048                                            args);
27049                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
27050                                            args);
27051    
27052                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
27053    
27054                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
27055                                            args);
27056                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
27057                                            args);
27058                            }
27059    
27060                            if ((journalArticleModelImpl.getColumnBitmask() &
27061                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
27062                                    Object[] args = new Object[] {
27063                                                    journalArticleModelImpl.getOriginalStructureId()
27064                                            };
27065    
27066                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
27067                                            args);
27068                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
27069                                            args);
27070    
27071                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
27072    
27073                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
27074                                            args);
27075                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
27076                                            args);
27077                            }
27078    
27079                            if ((journalArticleModelImpl.getColumnBitmask() &
27080                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
27081                                    Object[] args = new Object[] {
27082                                                    journalArticleModelImpl.getOriginalTemplateId()
27083                                            };
27084    
27085                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
27086                                            args);
27087                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
27088                                            args);
27089    
27090                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
27091    
27092                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
27093                                            args);
27094                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
27095                                            args);
27096                            }
27097    
27098                            if ((journalArticleModelImpl.getColumnBitmask() &
27099                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
27100                                    Object[] args = new Object[] {
27101                                                    journalArticleModelImpl.getOriginalLayoutUuid()
27102                                            };
27103    
27104                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
27105                                            args);
27106                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
27107                                            args);
27108    
27109                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
27110    
27111                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
27112                                            args);
27113                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
27114                                            args);
27115                            }
27116    
27117                            if ((journalArticleModelImpl.getColumnBitmask() &
27118                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
27119                                    Object[] args = new Object[] {
27120                                                    journalArticleModelImpl.getOriginalSmallImageId()
27121                                            };
27122    
27123                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
27124                                            args);
27125                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
27126                                            args);
27127    
27128                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
27129    
27130                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
27131                                            args);
27132                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
27133                                            args);
27134                            }
27135    
27136                            if ((journalArticleModelImpl.getColumnBitmask() &
27137                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
27138                                    Object[] args = new Object[] {
27139                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
27140                                                    journalArticleModelImpl.getOriginalStatus()
27141                                            };
27142    
27143                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
27144                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
27145                                            args);
27146    
27147                                    args = new Object[] {
27148                                                    journalArticleModelImpl.getResourcePrimKey(),
27149                                                    journalArticleModelImpl.getStatus()
27150                                            };
27151    
27152                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
27153                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
27154                                            args);
27155                            }
27156    
27157                            if ((journalArticleModelImpl.getColumnBitmask() &
27158                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
27159                                    Object[] args = new Object[] {
27160                                                    journalArticleModelImpl.getOriginalGroupId(),
27161                                                    journalArticleModelImpl.getOriginalUserId()
27162                                            };
27163    
27164                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
27165                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
27166                                            args);
27167    
27168                                    args = new Object[] {
27169                                                    journalArticleModelImpl.getGroupId(),
27170                                                    journalArticleModelImpl.getUserId()
27171                                            };
27172    
27173                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
27174                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
27175                                            args);
27176                            }
27177    
27178                            if ((journalArticleModelImpl.getColumnBitmask() &
27179                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
27180                                    Object[] args = new Object[] {
27181                                                    journalArticleModelImpl.getOriginalGroupId(),
27182                                                    journalArticleModelImpl.getOriginalFolderId()
27183                                            };
27184    
27185                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
27186                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
27187                                            args);
27188    
27189                                    args = new Object[] {
27190                                                    journalArticleModelImpl.getGroupId(),
27191                                                    journalArticleModelImpl.getFolderId()
27192                                            };
27193    
27194                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
27195                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
27196                                            args);
27197                            }
27198    
27199                            if ((journalArticleModelImpl.getColumnBitmask() &
27200                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
27201                                    Object[] args = new Object[] {
27202                                                    journalArticleModelImpl.getOriginalGroupId(),
27203                                                    journalArticleModelImpl.getOriginalArticleId()
27204                                            };
27205    
27206                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
27207                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
27208                                            args);
27209    
27210                                    args = new Object[] {
27211                                                    journalArticleModelImpl.getGroupId(),
27212                                                    journalArticleModelImpl.getArticleId()
27213                                            };
27214    
27215                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
27216                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
27217                                            args);
27218                            }
27219    
27220                            if ((journalArticleModelImpl.getColumnBitmask() &
27221                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
27222                                    Object[] args = new Object[] {
27223                                                    journalArticleModelImpl.getOriginalGroupId(),
27224                                                    journalArticleModelImpl.getOriginalUrlTitle()
27225                                            };
27226    
27227                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
27228                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
27229                                            args);
27230    
27231                                    args = new Object[] {
27232                                                    journalArticleModelImpl.getGroupId(),
27233                                                    journalArticleModelImpl.getUrlTitle()
27234                                            };
27235    
27236                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
27237                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
27238                                            args);
27239                            }
27240    
27241                            if ((journalArticleModelImpl.getColumnBitmask() &
27242                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
27243                                    Object[] args = new Object[] {
27244                                                    journalArticleModelImpl.getOriginalGroupId(),
27245                                                    journalArticleModelImpl.getOriginalStructureId()
27246                                            };
27247    
27248                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
27249                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
27250                                            args);
27251    
27252                                    args = new Object[] {
27253                                                    journalArticleModelImpl.getGroupId(),
27254                                                    journalArticleModelImpl.getStructureId()
27255                                            };
27256    
27257                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
27258                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
27259                                            args);
27260                            }
27261    
27262                            if ((journalArticleModelImpl.getColumnBitmask() &
27263                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
27264                                    Object[] args = new Object[] {
27265                                                    journalArticleModelImpl.getOriginalGroupId(),
27266                                                    journalArticleModelImpl.getOriginalTemplateId()
27267                                            };
27268    
27269                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
27270                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
27271                                            args);
27272    
27273                                    args = new Object[] {
27274                                                    journalArticleModelImpl.getGroupId(),
27275                                                    journalArticleModelImpl.getTemplateId()
27276                                            };
27277    
27278                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
27279                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
27280                                            args);
27281                            }
27282    
27283                            if ((journalArticleModelImpl.getColumnBitmask() &
27284                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
27285                                    Object[] args = new Object[] {
27286                                                    journalArticleModelImpl.getOriginalGroupId(),
27287                                                    journalArticleModelImpl.getOriginalLayoutUuid()
27288                                            };
27289    
27290                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
27291                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
27292                                            args);
27293    
27294                                    args = new Object[] {
27295                                                    journalArticleModelImpl.getGroupId(),
27296                                                    journalArticleModelImpl.getLayoutUuid()
27297                                            };
27298    
27299                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
27300                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
27301                                            args);
27302                            }
27303    
27304                            if ((journalArticleModelImpl.getColumnBitmask() &
27305                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
27306                                    Object[] args = new Object[] {
27307                                                    journalArticleModelImpl.getOriginalGroupId(),
27308                                                    journalArticleModelImpl.getOriginalStatus()
27309                                            };
27310    
27311                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
27312                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
27313                                            args);
27314    
27315                                    args = new Object[] {
27316                                                    journalArticleModelImpl.getGroupId(),
27317                                                    journalArticleModelImpl.getStatus()
27318                                            };
27319    
27320                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
27321                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
27322                                            args);
27323                            }
27324    
27325                            if ((journalArticleModelImpl.getColumnBitmask() &
27326                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
27327                                    Object[] args = new Object[] {
27328                                                    journalArticleModelImpl.getOriginalCompanyId(),
27329                                                    journalArticleModelImpl.getOriginalVersion()
27330                                            };
27331    
27332                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
27333                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
27334                                            args);
27335    
27336                                    args = new Object[] {
27337                                                    journalArticleModelImpl.getCompanyId(),
27338                                                    journalArticleModelImpl.getVersion()
27339                                            };
27340    
27341                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
27342                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
27343                                            args);
27344                            }
27345    
27346                            if ((journalArticleModelImpl.getColumnBitmask() &
27347                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
27348                                    Object[] args = new Object[] {
27349                                                    journalArticleModelImpl.getOriginalCompanyId(),
27350                                                    journalArticleModelImpl.getOriginalStatus()
27351                                            };
27352    
27353                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
27354                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
27355                                            args);
27356    
27357                                    args = new Object[] {
27358                                                    journalArticleModelImpl.getCompanyId(),
27359                                                    journalArticleModelImpl.getStatus()
27360                                            };
27361    
27362                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
27363                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
27364                                            args);
27365                            }
27366    
27367                            if ((journalArticleModelImpl.getColumnBitmask() &
27368                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
27369                                    Object[] args = new Object[] {
27370                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
27371                                                    journalArticleModelImpl.getOriginalIndexable(),
27372                                                    journalArticleModelImpl.getOriginalStatus()
27373                                            };
27374    
27375                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
27376                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
27377                                            args);
27378    
27379                                    args = new Object[] {
27380                                                    journalArticleModelImpl.getResourcePrimKey(),
27381                                                    journalArticleModelImpl.getIndexable(),
27382                                                    journalArticleModelImpl.getStatus()
27383                                            };
27384    
27385                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
27386                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
27387                                            args);
27388                            }
27389    
27390                            if ((journalArticleModelImpl.getColumnBitmask() &
27391                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
27392                                    Object[] args = new Object[] {
27393                                                    journalArticleModelImpl.getOriginalGroupId(),
27394                                                    journalArticleModelImpl.getOriginalFolderId(),
27395                                                    journalArticleModelImpl.getOriginalStatus()
27396                                            };
27397    
27398                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
27399                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
27400                                            args);
27401    
27402                                    args = new Object[] {
27403                                                    journalArticleModelImpl.getGroupId(),
27404                                                    journalArticleModelImpl.getFolderId(),
27405                                                    journalArticleModelImpl.getStatus()
27406                                            };
27407    
27408                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
27409                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
27410                                            args);
27411                            }
27412    
27413                            if ((journalArticleModelImpl.getColumnBitmask() &
27414                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
27415                                    Object[] args = new Object[] {
27416                                                    journalArticleModelImpl.getOriginalGroupId(),
27417                                                    journalArticleModelImpl.getOriginalClassNameId(),
27418                                                    journalArticleModelImpl.getOriginalClassPK()
27419                                            };
27420    
27421                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
27422                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
27423                                            args);
27424    
27425                                    args = new Object[] {
27426                                                    journalArticleModelImpl.getGroupId(),
27427                                                    journalArticleModelImpl.getClassNameId(),
27428                                                    journalArticleModelImpl.getClassPK()
27429                                            };
27430    
27431                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
27432                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
27433                                            args);
27434                            }
27435    
27436                            if ((journalArticleModelImpl.getColumnBitmask() &
27437                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
27438                                    Object[] args = new Object[] {
27439                                                    journalArticleModelImpl.getOriginalGroupId(),
27440                                                    journalArticleModelImpl.getOriginalClassNameId(),
27441                                                    journalArticleModelImpl.getOriginalTemplateId()
27442                                            };
27443    
27444                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
27445                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
27446                                            args);
27447    
27448                                    args = new Object[] {
27449                                                    journalArticleModelImpl.getGroupId(),
27450                                                    journalArticleModelImpl.getClassNameId(),
27451                                                    journalArticleModelImpl.getTemplateId()
27452                                            };
27453    
27454                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
27455                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
27456                                            args);
27457                            }
27458    
27459                            if ((journalArticleModelImpl.getColumnBitmask() &
27460                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
27461                                    Object[] args = new Object[] {
27462                                                    journalArticleModelImpl.getOriginalGroupId(),
27463                                                    journalArticleModelImpl.getOriginalClassNameId(),
27464                                                    journalArticleModelImpl.getOriginalLayoutUuid()
27465                                            };
27466    
27467                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
27468                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
27469                                            args);
27470    
27471                                    args = new Object[] {
27472                                                    journalArticleModelImpl.getGroupId(),
27473                                                    journalArticleModelImpl.getClassNameId(),
27474                                                    journalArticleModelImpl.getLayoutUuid()
27475                                            };
27476    
27477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
27478                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
27479                                            args);
27480                            }
27481    
27482                            if ((journalArticleModelImpl.getColumnBitmask() &
27483                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
27484                                    Object[] args = new Object[] {
27485                                                    journalArticleModelImpl.getOriginalGroupId(),
27486                                                    journalArticleModelImpl.getOriginalUserId(),
27487                                                    journalArticleModelImpl.getOriginalClassNameId()
27488                                            };
27489    
27490                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
27491                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
27492                                            args);
27493    
27494                                    args = new Object[] {
27495                                                    journalArticleModelImpl.getGroupId(),
27496                                                    journalArticleModelImpl.getUserId(),
27497                                                    journalArticleModelImpl.getClassNameId()
27498                                            };
27499    
27500                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
27501                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
27502                                            args);
27503                            }
27504    
27505                            if ((journalArticleModelImpl.getColumnBitmask() &
27506                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
27507                                    Object[] args = new Object[] {
27508                                                    journalArticleModelImpl.getOriginalGroupId(),
27509                                                    journalArticleModelImpl.getOriginalArticleId(),
27510                                                    journalArticleModelImpl.getOriginalStatus()
27511                                            };
27512    
27513                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
27514                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
27515                                            args);
27516    
27517                                    args = new Object[] {
27518                                                    journalArticleModelImpl.getGroupId(),
27519                                                    journalArticleModelImpl.getArticleId(),
27520                                                    journalArticleModelImpl.getStatus()
27521                                            };
27522    
27523                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
27524                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
27525                                            args);
27526                            }
27527    
27528                            if ((journalArticleModelImpl.getColumnBitmask() &
27529                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
27530                                    Object[] args = new Object[] {
27531                                                    journalArticleModelImpl.getOriginalGroupId(),
27532                                                    journalArticleModelImpl.getOriginalUrlTitle(),
27533                                                    journalArticleModelImpl.getOriginalStatus()
27534                                            };
27535    
27536                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
27537                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
27538                                            args);
27539    
27540                                    args = new Object[] {
27541                                                    journalArticleModelImpl.getGroupId(),
27542                                                    journalArticleModelImpl.getUrlTitle(),
27543                                                    journalArticleModelImpl.getStatus()
27544                                            };
27545    
27546                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
27547                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
27548                                            args);
27549                            }
27550    
27551                            if ((journalArticleModelImpl.getColumnBitmask() &
27552                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
27553                                    Object[] args = new Object[] {
27554                                                    journalArticleModelImpl.getOriginalCompanyId(),
27555                                                    journalArticleModelImpl.getOriginalVersion(),
27556                                                    journalArticleModelImpl.getOriginalStatus()
27557                                            };
27558    
27559                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
27560                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
27561                                            args);
27562    
27563                                    args = new Object[] {
27564                                                    journalArticleModelImpl.getCompanyId(),
27565                                                    journalArticleModelImpl.getVersion(),
27566                                                    journalArticleModelImpl.getStatus()
27567                                            };
27568    
27569                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
27570                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
27571                                            args);
27572                            }
27573                    }
27574    
27575                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27576                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
27577                            journalArticle);
27578    
27579                    clearUniqueFindersCache(journalArticle);
27580                    cacheUniqueFindersCache(journalArticle);
27581    
27582                    return journalArticle;
27583            }
27584    
27585            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
27586                    if (journalArticle instanceof JournalArticleImpl) {
27587                            return journalArticle;
27588                    }
27589    
27590                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
27591    
27592                    journalArticleImpl.setNew(journalArticle.isNew());
27593                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
27594    
27595                    journalArticleImpl.setUuid(journalArticle.getUuid());
27596                    journalArticleImpl.setId(journalArticle.getId());
27597                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
27598                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
27599                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
27600                    journalArticleImpl.setUserId(journalArticle.getUserId());
27601                    journalArticleImpl.setUserName(journalArticle.getUserName());
27602                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
27603                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
27604                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
27605                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
27606                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
27607                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
27608                    journalArticleImpl.setVersion(journalArticle.getVersion());
27609                    journalArticleImpl.setTitle(journalArticle.getTitle());
27610                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
27611                    journalArticleImpl.setDescription(journalArticle.getDescription());
27612                    journalArticleImpl.setContent(journalArticle.getContent());
27613                    journalArticleImpl.setType(journalArticle.getType());
27614                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
27615                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
27616                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
27617                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
27618                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
27619                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
27620                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
27621                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
27622                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
27623                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
27624                    journalArticleImpl.setStatus(journalArticle.getStatus());
27625                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
27626                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
27627                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
27628    
27629                    return journalArticleImpl;
27630            }
27631    
27632            /**
27633             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
27634             *
27635             * @param primaryKey the primary key of the journal article
27636             * @return the journal article
27637             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27638             * @throws SystemException if a system exception occurred
27639             */
27640            @Override
27641            public JournalArticle findByPrimaryKey(Serializable primaryKey)
27642                    throws NoSuchArticleException, SystemException {
27643                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
27644    
27645                    if (journalArticle == null) {
27646                            if (_log.isWarnEnabled()) {
27647                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
27648                            }
27649    
27650                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
27651                                    primaryKey);
27652                    }
27653    
27654                    return journalArticle;
27655            }
27656    
27657            /**
27658             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
27659             *
27660             * @param id the primary key of the journal article
27661             * @return the journal article
27662             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27663             * @throws SystemException if a system exception occurred
27664             */
27665            @Override
27666            public JournalArticle findByPrimaryKey(long id)
27667                    throws NoSuchArticleException, SystemException {
27668                    return findByPrimaryKey((Serializable)id);
27669            }
27670    
27671            /**
27672             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
27673             *
27674             * @param primaryKey the primary key of the journal article
27675             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
27676             * @throws SystemException if a system exception occurred
27677             */
27678            @Override
27679            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
27680                    throws SystemException {
27681                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27682                                    JournalArticleImpl.class, primaryKey);
27683    
27684                    if (journalArticle == _nullJournalArticle) {
27685                            return null;
27686                    }
27687    
27688                    if (journalArticle == null) {
27689                            Session session = null;
27690    
27691                            try {
27692                                    session = openSession();
27693    
27694                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
27695                                                    primaryKey);
27696    
27697                                    if (journalArticle != null) {
27698                                            cacheResult(journalArticle);
27699                                    }
27700                                    else {
27701                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27702                                                    JournalArticleImpl.class, primaryKey,
27703                                                    _nullJournalArticle);
27704                                    }
27705                            }
27706                            catch (Exception e) {
27707                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27708                                            JournalArticleImpl.class, primaryKey);
27709    
27710                                    throw processException(e);
27711                            }
27712                            finally {
27713                                    closeSession(session);
27714                            }
27715                    }
27716    
27717                    return journalArticle;
27718            }
27719    
27720            /**
27721             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
27722             *
27723             * @param id the primary key of the journal article
27724             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
27725             * @throws SystemException if a system exception occurred
27726             */
27727            @Override
27728            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
27729                    return fetchByPrimaryKey((Serializable)id);
27730            }
27731    
27732            /**
27733             * Returns all the journal articles.
27734             *
27735             * @return the journal articles
27736             * @throws SystemException if a system exception occurred
27737             */
27738            @Override
27739            public List<JournalArticle> findAll() throws SystemException {
27740                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27741            }
27742    
27743            /**
27744             * Returns a range of all the journal articles.
27745             *
27746             * <p>
27747             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27748             * </p>
27749             *
27750             * @param start the lower bound of the range of journal articles
27751             * @param end the upper bound of the range of journal articles (not inclusive)
27752             * @return the range of journal articles
27753             * @throws SystemException if a system exception occurred
27754             */
27755            @Override
27756            public List<JournalArticle> findAll(int start, int end)
27757                    throws SystemException {
27758                    return findAll(start, end, null);
27759            }
27760    
27761            /**
27762             * Returns an ordered range of all the journal articles.
27763             *
27764             * <p>
27765             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27766             * </p>
27767             *
27768             * @param start the lower bound of the range of journal articles
27769             * @param end the upper bound of the range of journal articles (not inclusive)
27770             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27771             * @return the ordered range of journal articles
27772             * @throws SystemException if a system exception occurred
27773             */
27774            @Override
27775            public List<JournalArticle> findAll(int start, int end,
27776                    OrderByComparator orderByComparator) throws SystemException {
27777                    boolean pagination = true;
27778                    FinderPath finderPath = null;
27779                    Object[] finderArgs = null;
27780    
27781                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
27782                                    (orderByComparator == null)) {
27783                            pagination = false;
27784                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
27785                            finderArgs = FINDER_ARGS_EMPTY;
27786                    }
27787                    else {
27788                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
27789                            finderArgs = new Object[] { start, end, orderByComparator };
27790                    }
27791    
27792                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
27793                                    finderArgs, this);
27794    
27795                    if (list == null) {
27796                            StringBundler query = null;
27797                            String sql = null;
27798    
27799                            if (orderByComparator != null) {
27800                                    query = new StringBundler(2 +
27801                                                    (orderByComparator.getOrderByFields().length * 3));
27802    
27803                                    query.append(_SQL_SELECT_JOURNALARTICLE);
27804    
27805                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27806                                            orderByComparator);
27807    
27808                                    sql = query.toString();
27809                            }
27810                            else {
27811                                    sql = _SQL_SELECT_JOURNALARTICLE;
27812    
27813                                    if (pagination) {
27814                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
27815                                    }
27816                            }
27817    
27818                            Session session = null;
27819    
27820                            try {
27821                                    session = openSession();
27822    
27823                                    Query q = session.createQuery(sql);
27824    
27825                                    if (!pagination) {
27826                                            list = (List<JournalArticle>)QueryUtil.list(q,
27827                                                            getDialect(), start, end, false);
27828    
27829                                            Collections.sort(list);
27830    
27831                                            list = new UnmodifiableList<JournalArticle>(list);
27832                                    }
27833                                    else {
27834                                            list = (List<JournalArticle>)QueryUtil.list(q,
27835                                                            getDialect(), start, end);
27836                                    }
27837    
27838                                    cacheResult(list);
27839    
27840                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
27841                            }
27842                            catch (Exception e) {
27843                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27844    
27845                                    throw processException(e);
27846                            }
27847                            finally {
27848                                    closeSession(session);
27849                            }
27850                    }
27851    
27852                    return list;
27853            }
27854    
27855            /**
27856             * Removes all the journal articles from the database.
27857             *
27858             * @throws SystemException if a system exception occurred
27859             */
27860            @Override
27861            public void removeAll() throws SystemException {
27862                    for (JournalArticle journalArticle : findAll()) {
27863                            remove(journalArticle);
27864                    }
27865            }
27866    
27867            /**
27868             * Returns the number of journal articles.
27869             *
27870             * @return the number of journal articles
27871             * @throws SystemException if a system exception occurred
27872             */
27873            @Override
27874            public int countAll() throws SystemException {
27875                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
27876                                    FINDER_ARGS_EMPTY, this);
27877    
27878                    if (count == null) {
27879                            Session session = null;
27880    
27881                            try {
27882                                    session = openSession();
27883    
27884                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
27885    
27886                                    count = (Long)q.uniqueResult();
27887    
27888                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
27889                                            FINDER_ARGS_EMPTY, count);
27890                            }
27891                            catch (Exception e) {
27892                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
27893                                            FINDER_ARGS_EMPTY);
27894    
27895                                    throw processException(e);
27896                            }
27897                            finally {
27898                                    closeSession(session);
27899                            }
27900                    }
27901    
27902                    return count.intValue();
27903            }
27904    
27905            @Override
27906            protected Set<String> getBadColumnNames() {
27907                    return _badColumnNames;
27908            }
27909    
27910            /**
27911             * Initializes the journal article persistence.
27912             */
27913            public void afterPropertiesSet() {
27914                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
27915                                            com.liferay.portal.util.PropsUtil.get(
27916                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
27917    
27918                    if (listenerClassNames.length > 0) {
27919                            try {
27920                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
27921    
27922                                    for (String listenerClassName : listenerClassNames) {
27923                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
27924                                                            getClassLoader(), listenerClassName));
27925                                    }
27926    
27927                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
27928                            }
27929                            catch (Exception e) {
27930                                    _log.error(e);
27931                            }
27932                    }
27933            }
27934    
27935            public void destroy() {
27936                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
27937                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
27938                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
27939                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
27940            }
27941    
27942            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
27943            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
27944            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
27945            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
27946            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
27947            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
27948            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
27949                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
27950            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
27951                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
27952            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
27953            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
27954            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
27955            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
27956            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
27957            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
27958            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
27959            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
27960            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
27961            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
27962                                    "uuid", "id", "type"
27963                            });
27964            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
27965                            @Override
27966                            public Object clone() {
27967                                    return this;
27968                            }
27969    
27970                            @Override
27971                            public CacheModel<JournalArticle> toCacheModel() {
27972                                    return _nullJournalArticleCacheModel;
27973                            }
27974                    };
27975    
27976            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
27977                            @Override
27978                            public JournalArticle toEntityModel() {
27979                                    return _nullJournalArticle;
27980                            }
27981                    };
27982    }